﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.BoundaryRepresentation;
using Autodesk.AutoCAD.Colors;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.Runtime;
using Autodesk.Windows;
using System.IO;
using FDEEInterface;
using FDEEPublicFunc;
using FDEEDrawingModels;
using System.Reflection;
using FDEE.Model;
using Autodesk.AutoCAD.Interop;
using ComTools;
using System.Globalization;
using System.Data;
using RegistCommon;

[assembly: ExtensionApplication(typeof(FDEEMain.Main))]
[assembly: CommandClass(typeof(FDEEMain.MainMaster))]
[assembly: CommandClass(typeof(FDEEMain.PileMaster))]
namespace FDEEMain
{
    public class Main : IExtensionApplication
    {
        bool isCreated = false;
        //接口实现
        public void Initialize()
        {
            try
            {
                //AddRibbon();//添加ribbon菜单的函数  
                CurPaht.curPaht = Path.GetDirectoryName(this.GetType().Assembly.Location) + "\\"; //获取程序集的加载路径
                string sysConfigPath = CurPaht.curPaht + "\\Config\\BridgeSetting.config";
                CurPaht.FirstInit =ConfigUtils.GetKey(sysConfigPath, "FirstInit");
                if (CurPaht.FirstInit == "2024")
                {
                    ConfigUtils.SetKey(sysConfigPath, "FirstInit", DateTime.Now.ToString("yyyyMMddHHmmss"));
                    AutoRegerit();
                    Autodesk.Windows.ComponentManager.ItemInitialized += this.ComponentManager_ItemInitialized;   //利用委托添加菜单
                    if (!isCreated)
                    {
                        AddRibbon();//添加ribbon菜单的函数  

                    }
                }
                else
                {
                    if (!isCreated)
                    {
                        if (RegistFileHelper.ExistRegistInfofile() == true)
                        {

                            string info = RegistFileHelper.ReadRegistFile();
                            if (UTool.CheckRegist(info) == true)
                            {
                                AddRibbon();//添加ribbon菜单的函数 
                            }
                            else
                            {
                                RegistForm frm = new RegistForm();
                                frm.ShowDialog();
                                if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                                {
                                    AddRibbon();//添加ribbon菜单的函数 
                                }
                                else
                                {
                                    return;
                                }
                            }
                        }
                        else
                        {
                            System.Windows.MessageBox.Show("缺少系统文件，请与管理员联系");
                        }
                    }
                }

            }
            catch (System.Exception ex)
            {

            }
        }
        public void Terminate()
        {
            throw new NotImplementedException();
        }
        public void ComponentManager_ItemInitialized(object sender, RibbonItemEventArgs e)
        {
            if (Autodesk.Windows.ComponentManager.Ribbon != null)
            {
                if (!isCreated)
                {
                    AddRibbon();//添加ribbon菜单的函数             
                    Autodesk.Windows.ComponentManager.ItemInitialized -= this.ComponentManager_ItemInitialized;
                }
            }
        }

        [CommandMethod("AddRibbon")]
        public void AddRibbon()
        {
            Autodesk.Windows.RibbonControl ribbonCtrl =
                Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl;
            RibbonTab tab = ribbonCtrl.AddTab("FDEE-T2-P2", "Acad.RibbonId1", true); //给Ribbon界面添加一个选项卡
            CurPaht.curPaht = Path.GetDirectoryName(this.GetType().Assembly.Location) + "\\"; //获取程序集的加载路径

            RibbonPanelSource panelSource0 = tab.AddPanel("设置"); //给选项卡添加面板
            panelSource0.Items.Add(RibbonButtonInfos.ProjectSettingBtn); //添加命令按钮

            RibbonPanelSource panelSource = tab.AddPanel("FDEE-T2"); //给选项卡添加面板
            panelSource.Items.Add(RibbonButtonInfos.PlotPileTableBtn); //添加命令按钮
            panelSource.Items.Add(RibbonButtonInfos.PlotTableBtn); //添加命令按钮
           
            panelSource.Items.Add(RibbonButtonInfos.PlotBatchColumnTableBtn); //添加命令按钮
            panelSource.Items.Add(RibbonButtonInfos.PlotBatchBeamTableBtn); //添加命令按钮
            panelSource.Items.Add(RibbonButtonInfos.PlotCrossBeamTableBtn); //添加命令按钮

            RibbonPanelSource panelSource1 = tab.AddPanel("垫石"); //给选项卡添加面板
            panelSource1.Items.Add(RibbonButtonInfos.PlotPlinthTableBtn); //添加命令按钮
            panelSource1.Items.Add(RibbonButtonInfos.PlotPlinthDepthTableBtn); //添加命令按钮



            RibbonPanelSource panelSource2 = tab.AddPanel("挡板"); //给选项卡添加面板
            //panelSource2.Items.Add(RibbonButtonInfos.PlotPlinthBlockTableBtn); //添加命令按钮
            panelSource2.Items.Add(RibbonButtonInfos.PlotPlinthBlockDepthTableBtn); //添加命令按钮          
            panelSource2.Items.Add(RibbonButtonInfos.PlotBlockDepthTableBtn); //添加命令按钮
            panelSource2.Items.Add(RibbonButtonInfos.PlotBlockRebarTableBtn); //添加命令按钮

            RibbonPanelSource panelSource3 = tab.AddPanel("盖梁构造图"); //给选项卡添加面板
            panelSource3.Items.Add(RibbonButtonInfos.PlotPlinthBtn); //添加命令按钮
            panelSource3.Items.Add(RibbonButtonInfos.PlotRampPlinthBtn); //添加命令按钮

            RibbonPanelSource panelSource4 = tab.AddPanel("桥面板"); //给选项卡添加面板
            panelSource4.Items.Add(RibbonButtonInfos.PlotDeckSlabTableBtn); //添加命令按钮
            panelSource4.Items.Add(RibbonButtonInfos.PlotDeckSlabRebarTableBtn); //添加命令按钮
            panelSource4.Items.Add(RibbonButtonInfos.PlotSCPlatRebarTableBtn); //添加命令按钮
            //panelSource4.Items.Add(RibbonButtonInfos.PlotDeckSlabCurveRebarTableBtn); //添加命令按钮
            panelSource4.Items.Add(RibbonButtonInfos.PlotRCPlatRebarTableBtn); //添加命令按钮

            RibbonPanelSource panelSource5 = tab.AddPanel("其它"); //给选项卡添加面板
            panelSource5.Items.Add(RibbonButtonInfos.PlotExcel2CADRebarTableBtn); //添加命令按钮
            panelSource5.Items.Add(RibbonButtonInfos.PlotExcel2PositionBarrierTableBtn); //添加命令按钮
            isCreated = true;
        
            Extensions.curPaht = CurPaht.curPaht;
            string sysConfigPath = CurPaht.curPaht + "\\Config\\BridgeSetting.config";
            Extensions.curTKPath = ConfigUtils.GetKey(sysConfigPath, "TK");
            if (!File.Exists(Extensions.curTKPath))
            {
                Extensions.curTKPath = "";
            }       
           string pileRowCount= ConfigUtils.GetKey(sysConfigPath, "PileCoorRowCount");
            try
            {
                Extensions.PileCoorRowCount = int.Parse(pileRowCount);
            }
            catch
            {

            }
            Extensions.curMapSheet = ConfigUtils.GetKey(sysConfigPath, "MapSheet");
            FDEEInterface.InitSetting.IniConfig();
        }

        public bool CheckRegist()
        {
            bool isRegist = false;
            try
            {

                if (RegistFileHelper.ExistRegistInfofile() == true)
                {

                    string info = RegistFileHelper.ReadRegistFile();
                    if (UTool.CheckRegist(info) == true)
                    {
                        if (!isCreated)
                        {
                            AddRibbon();//添加ribbon菜单的函数 
                        }
                        isRegist = true;
                    }
                    else
                    {
                        RegistForm frm = new RegistForm();
                        frm.ShowDialog();
                        if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                        {
                            if (!isCreated)
                            {
                                AddRibbon();//添加ribbon菜单的函数 
                            }
                            isRegist = true;
                        }
                        else
                        {
                            isRegist = false;
                        }
                    }
                }
                else
                {
                    System.Windows.MessageBox.Show("缺少系统文件，请与管理员联系");
                }

            }
            catch (System.Exception ex)
            {
             
            }
            return isRegist;
        }

        public void AutoRegerit()
        {
            //加密机器码
            string computer = ComputerInfo.GetComputerInfo(); 
            EncryptionHelper help = new EncryptionHelper(EncryptionKeyEnum.KeyB);
            string md5String = help.GetMD5String(computer);
            string registInfo = help.EncryptString(md5String);
            int i = registInfo.Length;
            //加密时间
            string dt = System.DateTime.Now.ToString();
            string timeout = "90";
            string timekey = help.EncryptString(dt + "&" + timeout);
            //输出注册码
            string key = registInfo + timekey;
            if (UTool.CheckRegist(key) == true)
            {
                System.Windows.MessageBox.Show("注册成功！");
            }
        }
    }

    public class MainMaster
    {

        #region 承台
        /// <summary>
        /// 承台
        /// </summary>
        [CommandMethod("SysSetting")]
        public static void SysSetting()
        {
            try
            {
                ConfigForm frm = new ConfigForm();
                frm.ShowDialog();
                if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    System.Windows.MessageBox.Show("设置成功！", "提示");
                }
            }
            catch (System.Exception ex)
            {

            }
        }
        #endregion

        #region 表格绘制
        /// <summary>
        /// 表格绘制
        /// </summary>
        [CommandMethod("PlotTable")]
        public static void PlotTable()
        {
            //去掉清楚模型空间
            Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();

            FDEEParamentForm frm = new FDEEParamentForm();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    // FDEE.Model.FPME41.
                    Type T = getObjectType(CurPaht.curPaht + @"FDEE.Model.dll", frm.para.type);
                    int num = 0;

                    RebarCollection reberList = new RebarCollection();
                    int OverAllScale = 1;
                    string structureName = "";
                    FDEE.Model.eConcreteClass eConType = FDEE.Model.eConcreteClass.None;
                    double conValue = 0;
                    string path = "";//构造物
                    //switch (frm.para.eType)
                    //{
                    //    case EStructure.E_PILE:             // 桩基
                    //        {

                    //            //path = CurPaht.curPaht + @"DWG\桩基块.dwg";//构造物
                    //            //PileBase ret = FDEE.Model.MemberFactory.CreatMember((EPileType)frm.para.eSubType, frm.pilePara.eHeightType, frm.pilePara.pileLength, (int)frm.pilePara.DOWEL);
                    //            //if (ret == null)
                    //            //{
                    //            //    throw new System.Exception("数据异常");
                    //            //}
                    //            //MemberBase reBase = ret as MemberBase;
                    //            //if (ret.RebarList != null && ret.RebarList.Count > 0)
                    //            //{
                    //            //    PloterTable.DrawingPileTable(db, reBase, frm.para.eType, path, frm.pilePara.type, frm.pilePara.pileLength, (int)frm.pilePara.DOWEL,
                    //            //        (FDEE.Model.eSubType)frm.para.nHeightType, eConType, conValue);
                    //            //}
                    //            //else
                    //            //{
                    //            //    throw new System.Exception("数据异常");
                    //            //}

                    //            //break;
                    //        }
                    //    case EStructure.E_FOOT:             // 承台
                    //        {
                                path = CurPaht.curPaht + @"DWG\block.dwg";//构造物
                                FootingBase ret;
                                if ((EFootingType)frm.footingPara.eSubType == EFootingType.FMHK)
                                {
                                    ret = MemberFactory.CreatMember("STA 0+236.604", EFootingType.FMHK, frm.footingPara.eHeightType, frm.footingPara.Length, frm.footingPara.ccpile, frm.footingPara.numpile, frm.footingPara.sidepile);
                                }
                                else
                                {
                                    ret = FDEE.Model.MemberFactory.CreatMember((EFootingType)frm.footingPara.eSubType, frm.footingPara.eHeightType);
                                }
                                string sql = "";
                                List<string> sqls = new List<string>();
                                //获取起步筋
                                try
                                {
                                    var kk = MemberFactory.CreatMember(MemberFactory.FromFootingToColumn((EFootingType)frm.footingPara.eSubType), frm.footingPara.eHeightType, 13728);
                                    var f = kk.RebarList;
                                    int sNo = 1;
                                    for (int i = 0; i < kk.RebarList.Count; ++i)
                                    {
                                        //同样的直径和类型合并
                                        if (kk.RebarList[i].MBarMark == 5 && kk.RebarList[i].SBarMark == 1)
                                        {
                                            RebarBase item = kk.RebarList[i];
                                            item.MBarMark = 6;
                                            item.SBarMark = sNo;
                                            item.CBarMark = "";
                                            ret.RebarList.Add(item);
                                            sNo++;
                                        }
                                    }
                                }
                                catch { }
                                if (ret == null)
                                {
                                    throw new System.Exception("数据异常");
                                }
                                string del = "";
                                string type = "";
                                MemberBase reBase = ret as MemberBase;
                                if (ret.RebarList != null && ret.RebarList.Count > 0)
                                {
                                    string typeName = ((EFootingType)frm.footingPara.eSubType).ToString();
                                    if (typeName.Contains("PE") || typeName.Contains("PME4"))
                                    {
                                        typeName = typeName.Replace("A", "").Replace("B", "").Substring(0, typeName.Length - 1) + "-" + typeName.Substring(typeName.Length - 1);
                                    }

                                    PloterTable.DrawingFootingTable(db, reBase, frm.para.eType, path, typeName, structureName,
                                        (FDEE.Model.eSubType)frm.para.nHeightType);
                                    Extensions.SaveActiveDrawing(db, typeName + "_承台钢筋" + DateTime.Now.ToString("yyyyMMddHHmm"));
                                    EFootingType etype = (EFootingType)frm.footingPara.eSubType;
                                    type = etype.ToString();
                                    del = string.Format("delete from t_footing where footing_type='{0}' ", type);
                                    try
                                    {
                                        MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                                    }
                                    catch { }
                                    for (int n = 0; n < reBase.RebarList.Count; n++)
                                    {
                                        RebarCollection tbValue = reBase.RebarList;
                                        string value = reBase.RebarList[n].MBarMark.ToString();
                                        if (reBase.RebarList[n].SBarMark != 0)
                                            value = reBase.RebarList[n].MBarMark.ToString() + "." + reBase.RebarList[n].SBarMark.ToString() + reBase.RebarList[n].CBarMark;
                                        else
                                            value = reBase.RebarList[n].MBarMark.ToString() + reBase.RebarList[n].CBarMark;
                                        if (reBase.RebarList[n].MBarMark != 6)
                                        {
                                            sql = string.Format("insert into t_footing(footing_type,bar_mark,"
             + "reinf_type,sharp_configuration,typical_formula,RR,dia,r,h,n,LX,A,B,C,D,"
             + "quantity,length,total_length,unit_weight,total_weight) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}')",
              type, value, tbValue[n].Diameter.ToString(), tbValue[n].ShapeConfg.ToString(), tbValue[n].Formula.ToString(),
             tbValue[n].R.ToString(), tbValue[n].d.ToString(), tbValue[n].r.ToString(), tbValue[n].h.ToString(), tbValue[n].n.ToString(), tbValue[n].Lx.ToString(), tbValue[n].A.ToString(), tbValue[n].B.ToString(),
              tbValue[n].C.ToString(), tbValue[n].D.ToString(), tbValue[n].Quantity.ToString(), tbValue[n].Length.ToString(), tbValue[n].TotalWeight.ToString(), tbValue[n].UnitWeight.ToString(), tbValue[n].TotalWeight.ToString());
                                            sqls.Add(sql);
                                        }
                                    }
                                }
                                else
                                {
                                    throw new System.Exception("数据异常");
                                }

                                Dictionary<eDB, List<RebarBase>> dic = new Dictionary<eDB, List<RebarBase>>();      // 统计合并项

                                #region 统计合并数据
                                foreach (RebarBase v in ret.RebarList)
                                {
                                    if (v.MBarMark != 6)
                                    {
                                        if (dic.Count == 0)
                                        {
                                            List<RebarBase> items = new List<RebarBase>();
                                            items.Add(v);
                                            dic[v.Diameter] = items;
                                        }
                                        else
                                        {
                                            List<RebarBase> items = new List<RebarBase>();
                                            dic.TryGetValue(v.Diameter, out items);
                                            if (items == null || items.Count == 0)
                                            {
                                                items = new List<RebarBase>();
                                            }
                                            items.Add(v);
                                            dic[v.Diameter] = items;
                                        }
                                    }
                                }
                                string concreteVolumn = ret.ConcreteVolumn.ToString("0.000");
                                string concrete = string.Format("fc={0}MPa", ret.ConcreteClass.ToString().Replace("C", ""));
                                double weight10 = 0;
                                double weight12 = 0;
                                double weight16 = 0;
                                double weight20 = 0;
                                double weight25 = 0;
                                double weight28 = 0;
                                double weight32 = 0;
                                double weight = 0;
                                foreach (var pr in dic)
                                {
                                    weight = 0;
                                    foreach (RebarBase info in pr.Value)
                                    {
                                        weight += info.TotalWeight;
                                    }
                                    if (pr.Key == eDB.DB10)
                                    {
                                        weight10 = weight;
                                    }
                                    else if (pr.Key == eDB.DB12)
                                    {
                                        weight12 = weight;
                                    }
                                    else if (pr.Key == eDB.DB16)
                                    {
                                        weight16 = weight;
                                    }
                                    else if (pr.Key == eDB.DB20)
                                    {
                                        weight20 = weight;
                                    }
                                    else if (pr.Key == eDB.DB25)
                                    {
                                        weight25 = weight;
                                    }
                                    else if (pr.Key == eDB.DB28)
                                    {
                                        weight28 = weight;
                                    }
                                    else if (pr.Key == eDB.DB32)
                                    {
                                        weight32 = weight;
                                    }
                                }
                                #endregion
                                double total = weight10 + weight12 + weight16 + weight20 + weight25 + weight28 + weight32;
                                try
                                {
                                    MySqlHelper.ExecuteNonQuery(sqls);
                                    del = string.Format("delete from t_footing_statistic where footing_type='{0}' ", type);
                                    MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                                    sql = string.Format("insert into t_footing_statistic(footing_type,concrete,concrete_volumn ,d10_weight,d12_weight,d16_weight,d20_weight,d25_weight,d28_weight,d32_weight,total)" +
                                        "values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')", type, concrete, concreteVolumn, weight10, weight12, weight16, weight20, weight25, weight28, weight32, total);
                                    MySqlHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text);


                                }
                                catch { }
                    //            break;
                    //        }

                    //    default:
                    //        break;
                    //}
                }
                catch (System.Exception ex)
                {
                    return;
                }
            }
        }
        #endregion

        #region 墩柱钢筋
        //[CommandMethod("PlotBatchColumnTable")]
        public static void PlotListColunmTable()
        {
            //去掉清楚模型空间
            //Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            BatchPlotCloumns frm = new BatchPlotCloumns();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {

                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    string[] piers = frm.pierParas.Split(',');
                    List<string> column = new List<string>(); //{ "P-316", "P-317", "P-318", "P-319", "P-320", "P-321", "P-322", "P-323", "P-324" };
                    List<int> columnHeight = new List<int>(); //{ 18257, 18257, 17757, 17757, 17757, 17757, 17757, 17757, 17540 };
                    for (int m = 0; m < piers.Length; m++)
                    {
                        string cN = piers[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[0];
                        string cNH = piers[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[1];
                        column.Add(cN);
                        columnHeight.Add(int.Parse(cNH));
                    }

                    Type T = getObjectType(CurPaht.curPaht + @"FDEE.Model.dll", frm.type);
                    eColumnType etype = (eColumnType)Enum.Parse(typeof(eColumnType), frm.type, true);
                    int num = 0;
                    RebarCollection reberList = new RebarCollection();
                    int OverAllScale = 1;
                    string structureName = "";
                    FDEE.Model.eSubType eHeightTyp = frm.eHeightType;
                    List<MemberBase> rets = new List<MemberBase>();
                    string typeName = "C-" + etype.ToString().Replace("C", "") + "-" + eHeightTyp.ToString();
                    if (etype.ToString().Contains("PE"))
                    {
                        string type = etype.ToString().Replace("C", "");
                        type = type.Substring(0, type.Length - 1) + "-" + type.Substring(type.Length - 1);
                        typeName = "C-" + type + "-" + eHeightTyp.ToString();
                    }
                    if (etype.ToString().Contains("PL"))
                    {
                        string type = etype.ToString().Replace("C", "");
                        type = type.Substring(0, type.Length - 1) + "-" + type.Substring(type.Length - 1);
                        typeName = "C-" + type;
                    }
                    int i = 0;
                    foreach (int item in columnHeight)
                    {


                        ColumnBase ret = FDEE.Model.MemberFactory.CreatMember(etype, eHeightTyp, item);
                        if (ret == null)
                        {
                            throw new System.Exception("数据异常");
                        }

                        MemberBase reBase = ret as MemberBase;
                        reBase.PierNumber = column[i];
                        rets.Add(reBase);

                        //if (i == 3)
                        //{
                        Extensions.ClearDatabase();
                        string path = CurPaht.curPaht + @"DWG\colunblock.dwg";//构造物
                        string pierName = "";
                        if (ret.RebarList != null && ret.RebarList.Count > 0)
                        {
                            string pierHeight = (item * 0.001).ToString();
                            pierName = column[i].ToString();
                            structureName = reBase.TypeName;
                            PloterTable.DrawingColumnTable(db, reBase, EStructure.E_COLUMN, path, etype.ToString(), structureName, pierHeight, pierName,
                               eHeightTyp, 1, frm.title, fsdTK);
                        }
                        else
                        {
                            throw new System.Exception("数据异常");
                        }

                        Extensions.SaveActiveDrawing(db, pierName + "_" + DateTime.Now.ToString("yyyyMMdd"), frm.title.Replace("RAMP", ""));
                        //Extensions.SaveActiveDrawing(pierName);
                        //}
                        System.Threading.Thread.Sleep(1000);
                        //trans.Commit();

                        i++;
                    }
                    if (rets.Count > 0)
                    {
                        Extensions.ClearDatabase();
                        Extents2d ext = new Extents2d(Point2d.Origin.Convert2D(0, 297 * 2), Point2d.Origin.Convert2D(0, 297 * 2));
                        Point2d CT = Point2d.Origin.Convert2D(0, 297 * 2);
                        Point2d M1 = CT.Convert2D(0, -2 * OverAllScale);
                        string title = "MAINLINE";
                        if (column.Contains("P-06") || column.Contains("P-07") || column.Contains("P-08"))
                            title = "RAMP BANANI EX-1";
                        int columnnum = 2;
                        if (etype.ToString().Contains("PE"))
                        {
                            columnnum = 1;
                        }
                        if (column.Contains("P-213R") || column.Contains("P-213L") || column.Contains("P-215R") || column.Contains("P-215L") || column.Contains("P-216R") || column.Contains("P-216L") || column.Contains("P-217R") || column.Contains("P-217L") || column.Contains("P-218R") || column.Contains("P-218L") || column.Contains("P-219R") || column.Contains("P-219L"))
                        {
                            columnnum = 1;
                        }
                        if (rets.Count > 9)
                        {

                            PloterTable.DrawColumnListMergeTB(db, rets, columnHeight, CT.Convert3D(),
                                                     Extensions.curFont, OverAllScale, typeName, title, columnnum);
                        }
                        else
                        {
                            //string title = "MAINLINE";
                            //if (column.Contains("P-06") || column.Contains("P-07") || column.Contains("P-08"))
                            //    title = "RAMP BANANI EX-1";
                            PloterTable.DrawColumnListMergeTable(db, rets, columnHeight, ref ext, CT.Convert3D(),
                                           Extensions.curFont, OverAllScale, typeName, title, columnnum);
                        }


                        Extensions.SaveActiveDrawing(db, typeName + "汇总" + "_" + DateTime.Now.ToString("yyyyMMddHHmm"), frm.title.Replace("RAMP", ""));

                    }
                }
                catch (System.Exception ex)
                {
                    return;
                }
            }

        }
        [CommandMethod("PlotBatchColumnTable")]
        public static void PlotColunmListTable()
        {
            //去掉清楚模型空间
            //Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            BatchPlotCloumns frm = new BatchPlotCloumns();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                Extensions.ClearDatabase();
                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    string[] piers = frm.pierParas.Split(',');
                    List<string> column = new List<string>(); //{ "P-316", "P-317", "P-318", "P-319", "P-320", "P-321", "P-322", "P-323", "P-324" };
                    List<int> columnHeight = new List<int>(); //{ 18257, 18257, 17757, 17757, 17757, 17757, 17757, 17757, 17540 };
                    string pierDiv = "";
                    for (int m = 0; m < piers.Length; m++)
                    {
                        string cN = piers[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[0];
                        string cNH = piers[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[1];
                        column.Add(cN);
                        columnHeight.Add(int.Parse(cNH));
                        if (m == 0)
                            pierDiv = cN.Replace("-", "");
                        if (m == piers.Length - 1)
                        {
                            if (piers.Length == 2)
                                pierDiv += "," + cN.Replace("-", "");
                            else
                                pierDiv += "-" + cN.Replace("-", "").Replace("RP", "").Replace("P", "");
                        }
                    }

                    Type T = getObjectType(CurPaht.curPaht + @"FDEE.Model.dll", frm.type);
                    eColumnType etype = (eColumnType)Enum.Parse(typeof(eColumnType), frm.type, true);
                    int num = 0;
                    RebarCollection reberList = new RebarCollection();
                    int OverAllScale = 1;
                    string structureName = "";
                    FDEE.Model.eSubType eHeightTyp = frm.eHeightType;
                    List<MemberBase> rets = new List<MemberBase>();
                    string typeName = "C-" + etype.ToString().Replace("C", "") + "-" + eHeightTyp.ToString();
                    if (etype.ToString().Contains("PE") || etype.ToString().Contains("PTE") || etype.ToString().Contains("PME"))
                    {
                        string type = etype.ToString().Replace("C", "").Replace("A", "").Replace("B", "");
                        type = type.Substring(0, type.Length - 1) + "-" + type.Substring(type.Length - 1);

                        typeName = "C-" + type + eHeightTyp.ToString().Replace("M", "*");
                        //if (column.Contains("RP11") || column.Contains("RP12") || column.Contains("RP13") || column.Contains("RP14"))
                        //typeName = "C-" + type + eHeightTyp.ToString().Replace("1", "*");
                    }
                    if (etype.ToString().Contains("PL"))
                        typeName = "C-" + etype.ToString().Replace("C", "");
                    int i = 0;
                    string title = "MAINLINE";
                    title = frm.title;
                    //if (column.Contains("RP-06") || column.Contains("RP-07") || column.Contains("RP-08"))
                    //    title = "RAMP BANANI EX-1";                 
                    //if (column.Contains("PR-01") || column.Contains("PR-02") || column.Contains("PR-03") || column.Contains("PR-04") || column.Contains("PR-05") || column.Contains("PR-06")
                    //   || column.Contains("PR-07") || column.Contains("PR-08") || column.Contains("PR-09") || column.Contains("PR-10") || column.Contains("PR-11") || column.Contains("PR-12") 
                    //   || column.Contains("PR-13") || column.Contains("PR-14") || column.Contains("PR-15") || column.Contains("PR-16") || column.Contains("PR-17") || column.Contains("PR-18") 
                    //   || column.Contains("PR-19") || column.Contains("PR-20") || column.Contains("PR-21"))
                    //    title = "RAMP MOHAKHALI EX-1";
                    //if (column.Contains("RP11") || column.Contains("RP12") || column.Contains("RP13") || column.Contains("RP14")
                    //    || column.Contains("RP17") || column.Contains("RP18") || column.Contains("RP19") || column.Contains("RP20") || column.Contains("RP21"))
                    //    title = "RAMP BANANI EX-2";
                    #region 墩柱钢筋
                    string pathR = CurPaht.curPaht + @"DWG\MainColumnRebar.dwg";//构造物
                    double _scale = 10;
                    if (frm.type == "CPTM3U")
                        _scale = 8;
                    PloterTable.DrawingColumnRebar(db, pathR, frm.type, eHeightTyp.ToString(), _scale, savePath);
                    #endregion

                    string sql = "";
                    List<string> sqls = new List<string>();
                    //foreach (int item in columnHeight)
                    for (int m = 0; m < columnHeight.Count; m++)
                    {
                        sqls = new List<string>();
                        int item = columnHeight[m];
                        string pierNo = column[m];
                        ColumnBase ret = FDEE.Model.MemberFactory.CreatMember(etype, eHeightTyp, item, pierNo);
                        if (ret == null)
                        {
                            throw new System.Exception("数据异常");
                        }

                        MemberBase reBase = ret as MemberBase;
                        reBase.PierNumber = column[i];
                        rets.Add(reBase);

                        //if (i == 3)
                        //{
                        //Extensions.ClearDatabase();
                        string path = CurPaht.curPaht + @"DWG\colunblock.dwg";//构造物
                        string pierName = "";
                        if (ret.RebarList != null && ret.RebarList.Count > 0)
                        {
                            string pierHeight = (item * 0.001).ToString();
                            pierName = column[i].ToString();
                            structureName = reBase.TypeName;
                            int pageCount = 0;
                            PloterTable.DrawingColumnTableNew(db, reBase, EStructure.E_COLUMN, path, typeName, structureName, pierHeight, pierName,
                               eHeightTyp, ref pageCount, i, 1, title, fsdTK);

                            string del = string.Format("delete from t_column where pier_number='{0}' and location='{1}'", pierName, title.Replace("RAMP ", ""));
                            try
                            {
                                MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                            }
                            catch { }
                            for (int n = 0; n < reBase.RebarList.Count; n++)
                            {
                                RebarCollection tbValue = reBase.RebarList;
                                string value = reBase.RebarList[n].MBarMark.ToString();
                                if (reBase.RebarList[n].SBarMark != 0)
                                    value = reBase.RebarList[n].MBarMark.ToString() + "." + reBase.RebarList[n].SBarMark.ToString() + reBase.RebarList[n].CBarMark;
                                else
                                    value = reBase.RebarList[n].MBarMark.ToString() + reBase.RebarList[n].CBarMark;
                                sql = string.Format("insert into t_column(type,location,pier_number ,pier_height,bar_mark,"
     + "reinf_type,sharp_configuration,typical_formula,RR,dia,r,h,n,LX,A,B,C,D,E,"
     + "quantity,length,total_length,unit_weight,total_weight) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}')",
     typeName, title.Replace("RAMP ", ""), pierName, pierHeight, value, tbValue[n].Diameter.ToString(), tbValue[n].ShapeConfg.ToString(), tbValue[n].Formula.ToString(),
     tbValue[n].R.ToString(), tbValue[n].d.ToString(), tbValue[n].r.ToString(), tbValue[n].h.ToString(), tbValue[n].n.ToString(), tbValue[n].Lx.ToString(), tbValue[n].A.ToString(), tbValue[n].B.ToString(),
      tbValue[n].C.ToString(), tbValue[n].D.ToString(), tbValue[n].E.ToString(), tbValue[n].Quantity.ToString(), tbValue[n].Length.ToString(), tbValue[n].TotalWeight.ToString(), tbValue[n].UnitWeight.ToString(), tbValue[n].TotalWeight.ToString());
                                sqls.Add(sql);
                            }

                            Dictionary<eDB, List<RebarBase>> dic = new Dictionary<eDB, List<RebarBase>>();      // 统计合并项

                            #region 统计合并数据
                            foreach (RebarBase v in ret.RebarList)
                            {
                                if (dic.Count == 0)
                                {
                                    List<RebarBase> items = new List<RebarBase>();
                                    items.Add(v);
                                    dic[v.Diameter] = items;
                                }
                                else
                                {
                                    List<RebarBase> items = new List<RebarBase>();
                                    dic.TryGetValue(v.Diameter, out items);
                                    if (items == null || items.Count == 0)
                                    {
                                        items = new List<RebarBase>();
                                    }
                                    items.Add(v);
                                    dic[v.Diameter] = items;
                                }
                            }
                            string concreteVolumn = ret.ConcreteVolumn.ToString("0.000");
                            string concrete = string.Format("fc={0}MPa", ret.ConcreteClass.ToString().Replace("C", ""));
                            double weight10 = 0;
                            double weight12 = 0;
                            double weight16 = 0;
                            double weight20 = 0;
                            double weight25 = 0;
                            double weight28 = 0;
                            double weight32 = 0;
                            double weight = 0;
                            foreach (var pr in dic)
                            {
                                weight = 0;
                                foreach (RebarBase info in pr.Value)
                                {
                                    weight += info.TotalWeight;
                                }
                                if (pr.Key == eDB.DB10)
                                {
                                    weight10 = weight;
                                }
                                else if (pr.Key == eDB.DB12)
                                {
                                    weight12 = weight;
                                }
                                else if (pr.Key == eDB.DB16)
                                {
                                    weight16 = weight;
                                }
                                else if (pr.Key == eDB.DB20)
                                {
                                    weight20 = weight;
                                }
                                else if (pr.Key == eDB.DB25)
                                {
                                    weight25 = weight;
                                }
                                else if (pr.Key == eDB.DB28)
                                {
                                    weight28 = weight;
                                }
                                else if (pr.Key == eDB.DB32)
                                {
                                    weight32 = weight;
                                }
                            }
                            double total = weight10 + weight12 + weight16 + weight20 + weight25 + weight28 + weight32;
                            #endregion
                            try
                            {
                                MySqlHelper.ExecuteNonQuery(sqls);
                                del = string.Format("delete from t_statistic where pier_number='{0}' and location='{1}'and type='{2}'", pierName, title.Replace("RAMP ", ""), "CL");
                                MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                                sql = string.Format("insert into t_statistic(location,type,pier_number,concrete,concrete_volumn ,d10_weight,d12_weight,d16_weight,d20_weight,d25_weight,d28_weight,d32_weight,pier_type,total)" +
                                    "values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}')", title.Replace("RAMP ", ""), "CL", pierName, concrete, concreteVolumn, weight10, weight12, weight16, weight20, weight25, weight28, weight32, etype.ToString().Replace("C", ""), total);
                                MySqlHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text);

                                pageCount += 1;

                                del = string.Format("delete from t_procedureoutinfo where pier_number='{0}' and location='{1}'and submite_position='{2}'", pierName, title.Replace("RAMP ", ""), "CL");
                                MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                                sql = string.Format("insert into t_procedureoutinfo(location,submite_position,pier_number,type,page_count)" +
                                    "values ('{0}','{1}','{2}','{3}','{4}')", title.Replace("RAMP ", ""), "CL", pierName, typeName, pageCount);
                                MySqlHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text);
                            }
                            catch { }
                        }
                        else
                        {
                            throw new System.Exception("数据异常");
                        }


                        //Extensions.SaveActiveDrawing(pierName);
                        //}
                        System.Threading.Thread.Sleep(1000);
                        //trans.Commit();

                        i++;
                    }

                    if (rets.Count > 0)
                    {
                        //Extensions.ClearDatabase();
                        Extents2d ext = new Extents2d(Point2d.Origin.Convert2D(0, 2 * 297), Point2d.Origin.Convert2D(0, 2 * 297));
                        Point2d CT = Point2d.Origin.Convert2D(0, 2 * 297);
                        Point2d M1 = CT.Convert2D(0, -2 * OverAllScale);

                        int columnnum = 2;
                        if (etype.ToString().Contains("PE"))
                        {
                            columnnum = 1;
                        }
                        if (column.Contains("P-213R") || column.Contains("P-214L") || column.Contains("P-214R") || column.Contains("P-213L") || column.Contains("P-215R") || column.Contains("P-215L") || column.Contains("P-216R") || column.Contains("P-216L") || column.Contains("P-217R") || column.Contains("P-217L") || column.Contains("P-218L") || column.Contains("P-219L") || column.Contains("P-218R") || column.Contains("P-219R"))
                        {
                            columnnum = 1;
                        }

                        if (rets.Count > 9)
                            PloterTable.DrawColumnListMergeTB(db, rets, columnHeight, CT.Convert3D(),
                                                 Extensions.curFont, OverAllScale, typeName, title, columnnum, fsdTK);
                        else
                            PloterTable.DrawColumnListMergeTable(db, rets, columnHeight, ref ext, CT.Convert3D(),
                                           Extensions.curFont, OverAllScale, typeName, title, columnnum, fsdTK);


                        //Extensions.SaveActiveDrawing(db, typeName.Replace("*", "") + "汇总"+ "(" + pierDiv + ")" + "_" + DateTime.Now.ToString("yyyyMMdd"), frm.title.Replace("RAMP", ""));

                    }
                    Extensions.SaveActiveDrawing(db, typeName.Replace("*", "") + "(" + pierDiv + ")_" + frm.title.Replace("RAMP", "").Replace(" ", "") + "_" + DateTime.Now.ToString("yyyyMMdd"), frm.title.Replace("RAMP", ""));
                }
                catch (System.Exception ex)
                {
                    return;
        #endregion
                }
            }

        }



        #region 盖梁钢筋
        //[CommandMethod("PlotBatchBeamTable")]
        public static void PlotBeamListTable()
        {
            //去掉清楚模型空间
            //Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            BatchBeamPlotForm frm = new BatchBeamPlotForm();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {

                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    string[] beams = frm.beamParas.Split(',');
                    List<string> columnNo = new List<string>(); //{ "P-316", "P-317", "P-318", "P-319", "P-320", "P-321", "P-322", "P-323", "P-324" };
                    List<int> beamLength = new List<int>(); //{ 18257, 18257, 17757, 17757, 17757, 17757, 17757, 17757, 17540 };
                    for (int m = 0; m < beams.Length; m++)
                    {
                        string cN = beams[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[0];
                        string cNH = beams[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[1];
                        columnNo.Add(cN);
                        beamLength.Add(int.Parse(cNH));
                    }
                    string title = "MAINLINE";
                    title = frm.title;

                    Type T = getObjectType(CurPaht.curPaht + @"FDEE.Model.dll", frm.type);
                    ECrossBeamType etype = (ECrossBeamType)Enum.Parse(typeof(ECrossBeamType), frm.type, true);
                    int num = 0;
                    RebarCollection reberList = new RebarCollection();
                    int OverAllScale = 1;
                    string structureName = "";
                    FDEE.Model.eSubType eHeightTyp = frm.eHeightType;
                    List<MemberBase> rets = new List<MemberBase>();
                    string typeName = "B-" + etype.ToString().Replace("B", "") + "-" + eHeightTyp.ToString();
                    if (etype.ToString().Contains("PE") || etype.ToString().Contains("PTE") || etype.ToString().Contains("PTL"))
                    {
                        string type = etype.ToString().Replace("C", "").Replace("A", "").Replace("B", "");
                        type = type.Substring(0, type.Length - 1) + "-" + type.Substring(type.Length - 1);

                        typeName = "B-" + type + eHeightTyp.ToString().Replace("M", "*");
                    }
                    if (etype.ToString().Contains("PL"))
                        typeName = "B-" + etype.ToString().Replace("B", "");
                    int i = 0;
                    Extensions.ClearDatabase();
                    string path = CurPaht.curPaht + @"DWG\BeamBlock.dwg";//构造物
                    List<int> DistinctInfo = beamLength.Distinct().ToList();
                    for (int m = 0; m < DistinctInfo.Count; m++)
                    {
                        double l = beamLength[m] * 0.001;
                        double _scale = 25;
                        if (etype.ToString().Contains("PE"))
                            _scale = 25;
                        else if (etype.ToString() == "BPTM1" || etype.ToString() == "BPTM1S" || etype.ToString() == "BPTM2" || etype.ToString() == "BPTM2S" || etype.ToString() == "BPTE3")
                            _scale = 12.5;
                        else if (etype.ToString() == "BPTM3S")
                            _scale = 10;
                        PloterTable.DrawingCapBeamRebarNew(db, path, l, frm.type, _scale, fsdTK, columnNo[i]);

                    }
                    string sql = "";
                    List<string> sqls = new List<string>();
                    foreach (int item in beamLength)
                    {
                        RebarCollection rebarList;
                        sqls = new List<string>();
                        MemberBase reBase;
                        string concreteVolumn = "";
                        string concrete = "";
                        if (title == "MAINLINE" || typeName.Contains("B-PTE-3") || typeName.Contains("B-PTE3-2") || typeName.Contains("B-PTE-2") || typeName.Contains("B-PL2") || typeName.Contains("B-PTL-2"))
                        {
                            CrossbeamBase ret = FDEE.Model.MemberFactory.CreatMember(etype, item, columnNo[i]);
                            if (ret == null)
                            {
                                throw new System.Exception("数据异常");
                            }

                            if (ret == null)
                            {
                                throw new System.Exception("数据异常");
                            }
                            //ret.RebarList
                            reBase = ret as MemberBase;
                            rebarList = ret.RebarList;
                            concreteVolumn = ret.ConcreteVolumn.ToString("0.000");
                            concrete = string.Format("fc={0}MPa", ret.ConcreteClass.ToString().Replace("C", ""));
                        }
                        else
                        {
                            RampCrossbeamBase ret = FDEE.Model.MemberFactory.CreatMember(etype, item, title.Replace("RAMP ", ""), columnNo[i]);
                            if (ret == null)
                            {
                                throw new System.Exception("数据异常");
                            }

                            if (ret == null)
                            {
                                throw new System.Exception("数据异常");
                            }

                            reBase = ret as MemberBase;
                            rebarList = ret.RebarList;
                        }
                        reBase.PierNumber = columnNo[i];
                        rets.Add(reBase);


                        path = CurPaht.curPaht + @"DWG\BeamBlock.dwg";//构造物
                        string pierName = "";
                        int pageCount = 1;
                        if (rebarList != null && rebarList.Count > 0)
                        {

                            string pierHeight = (item * 0.001).ToString();
                            pierName = columnNo[i].ToString();
                            structureName = reBase.TypeName;
                            //PloterTable.DrawingCapBeamTable(db, reBase, EStructure.E_CAPBEAM, path, frm.type, structureName, columnNo[i], (item * 0.001).ToString(), FDEE.Model.eSubType.None);
                            PloterTable.DrawingCapBeamTableNew(db, reBase, EStructure.E_CAPBEAM, path, frm.type, structureName, (item * 0.001).ToString(), columnNo[i], FDEE.Model.eSubType.None, ref pageCount, i, 1, title.Replace("RAMP ", ""), fsdTK);

                            string del = string.Format("delete from t_crossbeam where pier_number='{0}' and location='{1}'", pierName, title);
                            try
                            {
                                MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                            }
                            catch { }
                            for (int n = 0; n < reBase.RebarList.Count; n++)
                            {
                                RebarCollection tbValue = reBase.RebarList;
                                string value = reBase.RebarList[n].MBarMark.ToString();
                                if (reBase.RebarList[n].SBarMark != 0)
                                    value = reBase.RebarList[n].MBarMark.ToString() + "." + reBase.RebarList[n].SBarMark.ToString() + reBase.RebarList[n].CBarMark;
                                else
                                    value = reBase.RebarList[n].MBarMark.ToString() + reBase.RebarList[n].CBarMark;
                                sql = string.Format("insert into t_crossbeam(type,location,pier_number ,beam_length,bar_mark,"
     + "reinf_type,sharp_configuration,typical_formula,RR,dia,r,h,n,LX,A,B,C,D,"
     + "quantity,length,total_length,unit_weight,total_weight) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}')",
     typeName, title, pierName, (item * 0.001).ToString(), value, tbValue[n].Diameter.ToString(), tbValue[n].ShapeConfg.ToString(), tbValue[n].Formula.ToString(),
     tbValue[n].R.ToString(), tbValue[n].d.ToString(), tbValue[n].r.ToString(), tbValue[n].h.ToString(), tbValue[n].n.ToString(), tbValue[n].Lx.ToString(), tbValue[n].A.ToString(), tbValue[n].B.ToString(),
      tbValue[n].C.ToString(), tbValue[n].D.ToString(), tbValue[n].Quantity.ToString(), tbValue[n].Length.ToString(), tbValue[n].TotalWeight.ToString(), tbValue[n].UnitWeight.ToString(), tbValue[n].TotalWeight.ToString());
                                sqls.Add(sql);
                            }

                            Dictionary<eDB, List<RebarBase>> dic = new Dictionary<eDB, List<RebarBase>>();      // 统计合并项

                            #region 统计合并数据
                            foreach (RebarBase v in rebarList)
                            {
                                if (dic.Count == 0)
                                {
                                    List<RebarBase> items = new List<RebarBase>();
                                    items.Add(v);
                                    dic[v.Diameter] = items;
                                }
                                else
                                {
                                    List<RebarBase> items = new List<RebarBase>();
                                    dic.TryGetValue(v.Diameter, out items);
                                    if (items == null || items.Count == 0)
                                    {
                                        items = new List<RebarBase>();
                                    }
                                    items.Add(v);
                                    dic[v.Diameter] = items;
                                }
                            }

                            double weight10 = 0;
                            double weight12 = 0;
                            double weight16 = 0;
                            double weight20 = 0;
                            double weight25 = 0;
                            double weight28 = 0;
                            double weight32 = 0;
                            double weight = 0;
                            foreach (var pr in dic)
                            {
                                weight = 0;
                                foreach (RebarBase info in pr.Value)
                                {
                                    weight += info.TotalWeight;
                                }
                                if (pr.Key == eDB.DB10)
                                {
                                    weight10 = weight;
                                }
                                else if (pr.Key == eDB.DB12)
                                {
                                    weight12 = weight;
                                }
                                else if (pr.Key == eDB.DB16)
                                {
                                    weight16 = weight;
                                }
                                else if (pr.Key == eDB.DB20)
                                {
                                    weight20 = weight;
                                }
                                else if (pr.Key == eDB.DB25)
                                {
                                    weight25 = weight;
                                }
                                else if (pr.Key == eDB.DB28)
                                {
                                    weight28 = weight;
                                }
                                else if (pr.Key == eDB.DB32)
                                {
                                    weight32 = weight;
                                }
                            }
                            #endregion
                            double total = weight10 + weight12 + weight16 + weight20 + weight25 + weight28 + weight32;
                            try
                            {
                                MySqlHelper.ExecuteNonQuery(sqls);
                                del = string.Format("delete from t_statistic where pier_number='{0}' and location='{1}'and type='{2}'", pierName, title, "CB");
                                MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                                sql = string.Format("insert into t_statistic(location,type,pier_number,concrete,concrete_volumn ,d10_weight,d12_weight,d16_weight,d20_weight,d25_weight,d28_weight,d32_weight,pier_type,total)" +
                                    "values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}')", title, "CB", pierName, concrete, concreteVolumn, weight10, weight12, weight16, weight20, weight25, weight28, weight32, etype.ToString().Replace("B", ""), total);
                                MySqlHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text);


                                del = string.Format("delete from t_procedureoutinfo where pier_number='{0}' and location='{1}'and submite_position='{2}'", pierName, title.Replace("RAMP ", ""), "CB");
                                MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                                sql = string.Format("insert into t_procedureoutinfo(location,submite_position,pier_number,type,page_count)" +
                                    "values ('{0}','{1}','{2}','{3}','{4}')", title.Replace("RAMP ", ""), "CB", pierName, typeName, pageCount);
                                MySqlHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text);
                            }
                            catch { }
                        }
                        else
                        {
                            throw new System.Exception("数据异常");
                        }

                        //Extensions.SaveActiveDrawing(pierName);
                        //}
                        System.Threading.Thread.Sleep(1000);
                        //trans.Commit();

                        i++;
                    }

                    string pierL = columnNo[0] + "-" + columnNo[columnNo.Count - 1];
                    if (columnNo.Count == 1)
                        pierL = columnNo[0];
                    Extensions.SaveActiveDrawing(db, pierL + "_" + frm.type + "_" + frm.title.Replace("RAMP", "").Replace(" ", "") + "_盖梁钢筋" + DateTime.Now.ToString("yyyyMMdd"), frm.title.Replace("RAMP", ""));

                }
                catch (System.Exception ex)
                {
                    return;
                }
            }

        }
        //[CommandMethod("PlotBatchBeamTable")]
        public static void PlotBeamListTableByPier()
        {
            //去掉清楚模型空间
            //Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            BatchBeamPlotForm frm = new BatchBeamPlotForm();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    string[] beams = frm.beamParas.Split(',');
                    List<string> columnNo = new List<string>(); //{ "P-316", "P-317", "P-318", "P-319", "P-320", "P-321", "P-322", "P-323", "P-324" };
                    List<int> beamLength = new List<int>(); //{ 18257, 18257, 17757, 17757, 17757, 17757, 17757, 17757, 17540 };
                    for (int m = 0; m < beams.Length; m++)
                    {
                        string cN = beams[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[0];
                        string cNH = beams[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[1];
                        columnNo.Add(cN);
                        beamLength.Add(int.Parse(cNH));
                    }
                    string title = "MAINLINE";
                    title = frm.title;

                    Type T = getObjectType(CurPaht.curPaht + @"FDEE.Model.dll", frm.type);
                    ECrossBeamType etype = (ECrossBeamType)Enum.Parse(typeof(ECrossBeamType), frm.type, true);
                    int num = 0;
                    RebarCollection reberList = new RebarCollection();
                    int OverAllScale = 1;
                    string structureName = "";
                    FDEE.Model.eSubType eHeightTyp = frm.eHeightType;
                    List<MemberBase> rets = new List<MemberBase>();
                    string typeName = "B-" + etype.ToString().Replace("B", "") + "-" + eHeightTyp.ToString();
                    if (etype.ToString().Contains("PE") || etype.ToString().Contains("PTE"))
                    {
                        string type = etype.ToString().Replace("C", "").Replace("A", "").Replace("B", "");
                        type = type.Substring(0, type.Length - 1) + "-" + type.Substring(type.Length - 1);

                        typeName = "B-" + type + eHeightTyp.ToString().Replace("M", "*");
                    }
                    if (etype.ToString().Contains("PL"))
                        typeName = "B-" + etype.ToString().Replace("B", "");
                    int i = 0;
                    Extensions.ClearDatabase();
                    string sql = "";
                    List<string> sqls = new List<string>();
                    string path = CurPaht.curPaht + @"DWG\BeamBlock.dwg";//构造物
                    foreach (int item in beamLength)
                    {
                        Extensions.ClearDatabase();
                        double l = item * 0.001;
                        double _scale = 25;
                        if (etype.ToString().Contains("PE"))
                            _scale = 25;
                        else if (etype.ToString() == "BPTM1" || etype.ToString() == "BPTM1S" || etype.ToString() == "BPTM2" || etype.ToString() == "BPTM2S" || etype.ToString() == "BPTE3")
                            _scale = 12.5;
                        else if (etype.ToString() == "BPTM3S")
                            _scale = 10;
                        PloterTable.DrawingCapBeamRebarNew(db, path, l, frm.type, _scale, savePath);

                        RebarCollection rebarList;
                        sqls = new List<string>();
                        MemberBase reBase;
                        string concreteVolumn = "";
                        string concrete = "";
                        if (title == "MAINLINE" || typeName.Contains("B-PTE-3") || typeName.Contains("B-PTE3-2") || typeName.Contains("B-PTE-2"))
                        {
                            CrossbeamBase ret = FDEE.Model.MemberFactory.CreatMember(etype, item, columnNo[i]);
                            if (ret == null)
                            {
                                throw new System.Exception("数据异常");
                            }

                            if (ret == null)
                            {
                                throw new System.Exception("数据异常");
                            }
                            //ret.RebarList
                            reBase = ret as MemberBase;
                            rebarList = ret.RebarList;
                            concreteVolumn = ret.ConcreteVolumn.ToString("0.000");
                            concrete = string.Format("fc={0}MPa", ret.ConcreteClass.ToString().Replace("C", ""));
                        }
                        else
                        {
                            RampCrossbeamBase ret = FDEE.Model.MemberFactory.CreatMember(etype, item, title.Replace("RAMP ", ""), columnNo[i]);
                            if (ret == null)
                            {
                                throw new System.Exception("数据异常");
                            }

                            if (ret == null)
                            {
                                throw new System.Exception("数据异常");
                            }

                            reBase = ret as MemberBase;
                            rebarList = ret.RebarList;
                        }
                        reBase.PierNumber = columnNo[i];
                        rets.Add(reBase);


                        //string path = CurPaht.curPaht + @"DWG\BeamBlock.dwg";//构造物
                        string pierName = "";
                        int pageCount = 1;
                        if (rebarList != null && rebarList.Count > 0)
                        {
                            string pierHeight = (item * 0.001).ToString();
                            pierName = columnNo[i].ToString();
                            structureName = reBase.TypeName;

                            //PloterTable.DrawingCapBeamTable(db, reBase, EStructure.E_CAPBEAM, path, frm.type, structureName, columnNo[i], (item * 0.001).ToString(), FDEE.Model.eSubType.None);
                            if (frm.type == "BPTM2")
                                PloterBeamTable.DrawingCapBeamTableNew(db, reBase, EStructure.E_CAPBEAM, path, frm.type, structureName, (item * 0.001).ToString(), columnNo[i], FDEE.Model.eSubType.None, ref pageCount, 0, 1, title.Replace("RAMP ", ""));
                            else
                                PloterTable.DrawingCapBeamTableNew(db, reBase, EStructure.E_CAPBEAM, path, frm.type, structureName, (item * 0.001).ToString(), columnNo[i], FDEE.Model.eSubType.None, ref pageCount, 0, 1, title.Replace("RAMP ", ""));

                            string del = string.Format("delete from t_crossbeam where pier_number='{0}' and location='{1}'", pierName, title);
                            try
                            {
                                MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                            }
                            catch { }
                            for (int n = 0; n < reBase.RebarList.Count; n++)
                            {
                                RebarCollection tbValue = reBase.RebarList;
                                string value = reBase.RebarList[n].MBarMark.ToString();
                                if (reBase.RebarList[n].SBarMark != 0)
                                    value = reBase.RebarList[n].MBarMark.ToString() + "." + reBase.RebarList[n].SBarMark.ToString() + reBase.RebarList[n].CBarMark;
                                else
                                    value = reBase.RebarList[n].MBarMark.ToString() + reBase.RebarList[n].CBarMark;
                                sql = string.Format("insert into t_crossbeam(type,location,pier_number ,beam_length,bar_mark,"
     + "reinf_type,sharp_configuration,typical_formula,RR,dia,r,h,n,LX,A,B,C,D,"
     + "quantity,length,total_length,unit_weight,total_weight) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}')",
     typeName, title, pierName, (item * 0.001).ToString(), value, tbValue[n].Diameter.ToString(), tbValue[n].ShapeConfg.ToString(), tbValue[n].Formula.ToString(),
     tbValue[n].R.ToString(), tbValue[n].d.ToString(), tbValue[n].r.ToString(), tbValue[n].h.ToString(), tbValue[n].n.ToString(), tbValue[n].Lx.ToString(), tbValue[n].A.ToString(), tbValue[n].B.ToString(),
      tbValue[n].C.ToString(), tbValue[n].D.ToString(), tbValue[n].Quantity.ToString(), tbValue[n].Length.ToString(), tbValue[n].TotalWeight.ToString(), tbValue[n].UnitWeight.ToString(), tbValue[n].TotalWeight.ToString());
                                sqls.Add(sql);
                            }

                            Dictionary<eDB, List<RebarBase>> dic = new Dictionary<eDB, List<RebarBase>>();      // 统计合并项

                            #region 统计合并数据
                            foreach (RebarBase v in rebarList)
                            {
                                if (dic.Count == 0)
                                {
                                    List<RebarBase> items = new List<RebarBase>();
                                    items.Add(v);
                                    dic[v.Diameter] = items;
                                }
                                else
                                {
                                    List<RebarBase> items = new List<RebarBase>();
                                    dic.TryGetValue(v.Diameter, out items);
                                    if (items == null || items.Count == 0)
                                    {
                                        items = new List<RebarBase>();
                                    }
                                    items.Add(v);
                                    dic[v.Diameter] = items;
                                }
                            }

                            double weight10 = 0;
                            double weight12 = 0;
                            double weight16 = 0;
                            double weight20 = 0;
                            double weight25 = 0;
                            double weight28 = 0;
                            double weight32 = 0;
                            double weight = 0;
                            foreach (var pr in dic)
                            {
                                weight = 0;
                                foreach (RebarBase info in pr.Value)
                                {
                                    weight += info.TotalWeight;
                                }
                                if (pr.Key == eDB.DB10)
                                {
                                    weight10 = weight;
                                }
                                else if (pr.Key == eDB.DB12)
                                {
                                    weight12 = weight;
                                }
                                else if (pr.Key == eDB.DB16)
                                {
                                    weight16 = weight;
                                }
                                else if (pr.Key == eDB.DB20)
                                {
                                    weight20 = weight;
                                }
                                else if (pr.Key == eDB.DB25)
                                {
                                    weight25 = weight;
                                }
                                else if (pr.Key == eDB.DB28)
                                {
                                    weight28 = weight;
                                }
                                else if (pr.Key == eDB.DB32)
                                {
                                    weight32 = weight;
                                }
                            }
                            #endregion
                            double total = weight10 + weight12 + weight16 + weight20 + weight25 + weight28 + weight32;
                            try
                            {
                                MySqlHelper.ExecuteNonQuery(sqls);
                                del = string.Format("delete from t_statistic where pier_number='{0}' and location='{1}'and type='{2}'", pierName, title, "CB");
                                MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                                sql = string.Format("insert into t_statistic(location,type,pier_number,concrete,concrete_volumn ,d10_weight,d12_weight,d16_weight,d20_weight,d25_weight,d28_weight,d32_weight,pier_type,total)" +
                                    "values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}')", title, "CB", pierName, concrete, concreteVolumn, weight10, weight12, weight16, weight20, weight25, weight28, weight32, etype.ToString().Replace("B", ""), total);
                                MySqlHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text);


                                del = string.Format("delete from t_procedureoutinfo where pier_number='{0}' and location='{1}'and submite_position='{2}'", pierName, title.Replace("RAMP ", ""), "CB");
                                MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                                sql = string.Format("insert into t_procedureoutinfo(location,submite_position,pier_number,type,page_count)" +
                                    "values ('{0}','{1}','{2}','{3}','{4}')", title.Replace("RAMP ", ""), "CB", pierName, typeName, pageCount);
                                MySqlHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text);
                            }
                            catch { }
                        }
                        else
                        {
                            throw new System.Exception("数据异常");
                        }

                        //Extensions.SaveActiveDrawing(pierName);
                        //}
                        System.Threading.Thread.Sleep(10);
                        //trans.Commit();

                        i++;
                    }

                    //string pierL = columnNo[0] + "-" + columnNo[columnNo.Count - 1];
                    //if (columnNo.Count == 1)
                    //    pierL = columnNo[0];
                    //Extensions.SaveActiveDrawing(db, pierL + "_" + frm.type + "_盖梁钢筋" + DateTime.Now.ToString("yyyyMMdd"));

                }
                catch (System.Exception ex)
                {
                    return;
                }
            }

        }
        #endregion

        #region  主线盖梁钢筋、算量以及预应力构造、算量合并
        [CommandMethod("PlotBatchBeamTable")]
        public static void PlotMainBeamListTableByPier()
        {
            //去掉清楚模型空间
            //Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            BatchBeamPlotForm frm = new BatchBeamPlotForm();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    string[] beams = frm.beamParas.Split(',');
                    List<string> columnNo = new List<string>(); //{ "P-316", "P-317", "P-318", "P-319", "P-320", "P-321", "P-322", "P-323", "P-324" };
                    List<int> beamLength = new List<int>(); //{ 18257, 18257, 17757, 17757, 17757, 17757, 17757, 17757, 17540 };
                    for (int m = 0; m < beams.Length; m++)
                    {
                        string cN = beams[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[0];
                        string cNH = beams[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[1];
                        columnNo.Add(cN);
                        beamLength.Add(int.Parse(cNH));
                    }
                    string title = "MAINLINE";
                    title = frm.title;

                    Type T = getObjectType(CurPaht.curPaht + @"FDEE.Model.dll", frm.type);
                    ECrossBeamType etype = (ECrossBeamType)Enum.Parse(typeof(ECrossBeamType), frm.type, true);
                    int num = 0;
                    RebarCollection reberList = new RebarCollection();
                    int OverAllScale = 1;
                    string structureName = "";
                    FDEE.Model.eSubType eHeightTyp = frm.eHeightType;
                    //List<MemberBase> rets = new List<MemberBase>();
                    string typeName = "B-" + etype.ToString().Replace("B", "") + "-" + eHeightTyp.ToString();
                    if (etype.ToString().Contains("PE") || etype.ToString().Contains("PTE"))
                    {
                        string type = etype.ToString().Replace("C", "").Replace("A", "").Replace("B", "");
                        type = type.Substring(0, type.Length - 1) + "-" + type.Substring(type.Length - 1);

                        typeName = "B-" + type + eHeightTyp.ToString().Replace("M", "*");
                    }
                    if (etype.ToString().Contains("PL"))
                        typeName = "B-" + etype.ToString().Replace("B", "");
                    int i = 0;

                    System.Data.DataTable dt = new System.Data.DataTable();
                    dt.Columns.Add("Num", System.Type.GetType("System.String"));
                    dt.Columns.Add("PierNo", System.Type.GetType("System.String"));
                    dt.Columns.Add("No", System.Type.GetType("System.String"));
                    dt.Columns.Add("CurveLength", System.Type.GetType("System.String"));
                    dt.Columns.Add("StraightLength", System.Type.GetType("System.String"));
                    dt.Columns.Add("TheoricalLength", System.Type.GetType("System.String"));
                    dt.Columns.Add("AAnchorB", System.Type.GetType("System.String"));
                    dt.Columns.Add("0.02", System.Type.GetType("System.String"));
                    dt.Columns.Add("PAnchorB", System.Type.GetType("System.String"));
                    dt.Columns.Add("DuctLength", System.Type.GetType("System.String"));
                    dt.Columns.Add("0.2", System.Type.GetType("System.String"));
                    dt.Columns.Add("AAnchorReserve", System.Type.GetType("System.String"));
                    dt.Columns.Add("0.020", System.Type.GetType("System.String"));
                    dt.Columns.Add("AAnchorF", System.Type.GetType("System.String"));
                    dt.Columns.Add("0.2000", System.Type.GetType("System.String"));
                    dt.Columns.Add("Length", System.Type.GetType("System.String"));
                    dt.Columns.Add("fpj", System.Type.GetType("System.String"));
                    dt.Columns.Add("Elongation", System.Type.GetType("System.String"));
                    dt.Columns.Add("Degres", System.Type.GetType("System.String"));

                    Extensions.ClearDatabase();
                    string sql = "";
                    List<string> sqls = new List<string>();
                    string path = CurPaht.curPaht + @"DWG\BeamBlock.dwg";//构造物
                    foreach (int item in beamLength)
                    {
                        Extensions.ClearDatabase();
                        double l = item * 0.001;
                        double _scale = 25;
                        if (etype.ToString().Contains("PE"))
                            _scale = 25;
                        else if (etype.ToString() == "BPTM1" || etype.ToString() == "BPTM1S" || etype.ToString() == "BPTM2" || etype.ToString() == "BPTM2S" || etype.ToString() == "BPTE3")
                            _scale = 12.5;
                        else if (etype.ToString() == "BPTM3S")
                            _scale = 10;
                        PloterTable.DrawingCapBeamRebarNew(db, path, l, frm.type, _scale, savePath);

                        RebarCollection rebarList;
                        sqls = new List<string>();
                        MemberBase reBase;
                        string concreteVolumn = "";
                        string concrete = "";
                        if (title == "MAINLINE" || typeName.Contains("B-PTE-3") || typeName.Contains("B-PTE3-2") || typeName.Contains("B-PTE-2"))
                        {
                            CrossbeamBase ret = FDEE.Model.MemberFactory.CreatMember(etype, item, columnNo[i]);
                            if (ret == null)
                            {
                                throw new System.Exception("数据异常");
                            }

                            if (ret == null)
                            {
                                throw new System.Exception("数据异常");
                            }
                            //ret.RebarList
                            reBase = ret as MemberBase;
                            rebarList = ret.RebarList;
                            concreteVolumn = ret.ConcreteVolumn.ToString("0.000");
                            concrete = string.Format("fc={0}MPa", ret.ConcreteClass.ToString().Replace("C", ""));
                        }
                        else
                        {
                            RampCrossbeamBase ret = FDEE.Model.MemberFactory.CreatMember(etype, item, title.Replace("RAMP ", ""), columnNo[i]);
                            if (ret == null)
                            {
                                throw new System.Exception("数据异常");
                            }

                            if (ret == null)
                            {
                                throw new System.Exception("数据异常");
                            }

                            reBase = ret as MemberBase;
                            rebarList = ret.RebarList;
                        }
                        reBase.PierNumber = columnNo[i];
                        //rets.Add(reBase);

                        string pierName = "";
                        int pageCount = 1;
                        if (rebarList != null && rebarList.Count > 0)
                        {
                            string pierHeight = (item * 0.001).ToString();
                            pierName = columnNo[i].ToString();
                            structureName = reBase.TypeName;

                            //PloterTable.DrawingCapBeamTable(db, reBase, EStructure.E_CAPBEAM, path, frm.type, structureName, columnNo[i], (item * 0.001).ToString(), FDEE.Model.eSubType.None);
                            if (frm.type == "BPTM2")
                                PloterBeamTable.DrawingCapBeamTableNew(db, reBase, EStructure.E_CAPBEAM, path, frm.type, structureName, (item * 0.001).ToString(), columnNo[i], FDEE.Model.eSubType.None, ref pageCount, 0, 1, title.Replace("RAMP ", ""));
                            else
                                PloterTable.DrawingCapBeamTableNew(db, reBase, EStructure.E_CAPBEAM, path, frm.type, structureName, (item * 0.001).ToString(), columnNo[i], FDEE.Model.eSubType.None, ref pageCount, 0, 1, title.Replace("RAMP ", ""));

                            string del = string.Format("delete from t_crossbeam where pier_number='{0}' and location='{1}'", pierName, title);
                            try
                            {
                                MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                            }
                            catch { }
                            for (int n = 0; n < reBase.RebarList.Count; n++)
                            {
                                RebarCollection tbValue = reBase.RebarList;
                                string value = reBase.RebarList[n].MBarMark.ToString();
                                if (reBase.RebarList[n].SBarMark != 0)
                                    value = reBase.RebarList[n].MBarMark.ToString() + "." + reBase.RebarList[n].SBarMark.ToString() + reBase.RebarList[n].CBarMark;
                                else
                                    value = reBase.RebarList[n].MBarMark.ToString() + reBase.RebarList[n].CBarMark;
                                sql = string.Format("insert into t_crossbeam(type,location,pier_number ,beam_length,bar_mark,"
     + "reinf_type,sharp_configuration,typical_formula,RR,dia,r,h,n,LX,A,B,C,D,"
     + "quantity,length,total_length,unit_weight,total_weight) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}')",
     typeName, title, pierName, (item * 0.001).ToString(), value, tbValue[n].Diameter.ToString(), tbValue[n].ShapeConfg.ToString(), tbValue[n].Formula.ToString(),
     tbValue[n].R.ToString(), tbValue[n].d.ToString(), tbValue[n].r.ToString(), tbValue[n].h.ToString(), tbValue[n].n.ToString(), tbValue[n].Lx.ToString(), tbValue[n].A.ToString(), tbValue[n].B.ToString(),
      tbValue[n].C.ToString(), tbValue[n].D.ToString(), tbValue[n].Quantity.ToString(), tbValue[n].Length.ToString(), tbValue[n].TotalWeight.ToString(), tbValue[n].UnitWeight.ToString(), tbValue[n].TotalWeight.ToString());
                                sqls.Add(sql);
                            }

                            Dictionary<eDB, List<RebarBase>> dic = new Dictionary<eDB, List<RebarBase>>();      // 统计合并项

                            #region 统计合并数据
                            foreach (RebarBase v in rebarList)
                            {
                                if (dic.Count == 0)
                                {
                                    List<RebarBase> items = new List<RebarBase>();
                                    items.Add(v);
                                    dic[v.Diameter] = items;
                                }
                                else
                                {
                                    List<RebarBase> items = new List<RebarBase>();
                                    dic.TryGetValue(v.Diameter, out items);
                                    if (items == null || items.Count == 0)
                                    {
                                        items = new List<RebarBase>();
                                    }
                                    items.Add(v);
                                    dic[v.Diameter] = items;
                                }
                            }

                            double weight10 = 0;
                            double weight12 = 0;
                            double weight16 = 0;
                            double weight20 = 0;
                            double weight25 = 0;
                            double weight28 = 0;
                            double weight32 = 0;
                            double weight = 0;
                            foreach (var pr in dic)
                            {
                                weight = 0;
                                foreach (RebarBase info in pr.Value)
                                {
                                    weight += info.TotalWeight;
                                }
                                if (pr.Key == eDB.DB10)
                                {
                                    weight10 = weight;
                                }
                                else if (pr.Key == eDB.DB12)
                                {
                                    weight12 = weight;
                                }
                                else if (pr.Key == eDB.DB16)
                                {
                                    weight16 = weight;
                                }
                                else if (pr.Key == eDB.DB20)
                                {
                                    weight20 = weight;
                                }
                                else if (pr.Key == eDB.DB25)
                                {
                                    weight25 = weight;
                                }
                                else if (pr.Key == eDB.DB28)
                                {
                                    weight28 = weight;
                                }
                                else if (pr.Key == eDB.DB32)
                                {
                                    weight32 = weight;
                                }
                            }
                            #endregion
                            double total = weight10 + weight12 + weight16 + weight20 + weight25 + weight28 + weight32;
                            try
                            {
                                MySqlHelper.ExecuteNonQuery(sqls);
                                del = string.Format("delete from t_statistic where pier_number='{0}' and location='{1}'and type='{2}'", pierName, title, "CB");
                                MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                                sql = string.Format("insert into t_statistic(location,type,pier_number,concrete,concrete_volumn ,d10_weight,d12_weight,d16_weight,d20_weight,d25_weight,d28_weight,d32_weight,pier_type,total)" +
                                    "values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}')", title, "CB", pierName, concrete, concreteVolumn, weight10, weight12, weight16, weight20, weight25, weight28, weight32, etype.ToString().Replace("B", ""), total);
                                MySqlHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text);


                                del = string.Format("delete from t_procedureoutinfo where pier_number='{0}' and location='{1}'and submite_position='{2}'", pierName, title.Replace("RAMP ", ""), "CB");
                                MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                                sql = string.Format("insert into t_procedureoutinfo(location,submite_position,pier_number,type,page_count)" +
                                    "values ('{0}','{1}','{2}','{3}','{4}')", title.Replace("RAMP ", ""), "CB", pierName, typeName, pageCount);
                                MySqlHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text);
                            }
                            catch { }
                        }
                        else
                        {
                            throw new System.Exception("数据异常");
                        }



                        System.Threading.Thread.Sleep(10);

                        List<MemberBase> rets = new List<MemberBase>();

                        rets.Add(reBase);
                        //Extensions.ClearDatabase();
                        if (title == "MAINLINE")
                        {
                            pageCount = 1;
                            Dictionary<string, System.Data.DataTable> dicP = new Dictionary<string, System.Data.DataTable>();
                            PlotCrossBeamTable.DrawingCapBeamTableNew(db, rets, EStructure.E_CAPBEAM, path, frm.type, ref dt, ref dicP, ref pageCount, 1, title.Replace("RAMP ", ""), fsdTK);

                            try
                            {
                                   List<string> sqlList = new List<string>();

                                if (dicP.Count > 0)
                                {
                                    for (int m = 0; m < dicP.Count; m++)
                                    {
                                        string sqlT;
                                        string delT = string.Format("delete from t_tendon where pier_number='{0}' and location='{1}'", dicP.Keys.ToList()[m], title.Replace("RAMP ", ""));
                                        MySqlHelper.ExecuteNonQuery(delT, System.Data.CommandType.Text);

                                        foreach (System.Data.DataRow dr in dt.Rows)
                                        {
                                            sqlT = string.Format("insert into t_tendon(location,pier_number,no,CurveLength,StraightLength,TheoricalLength,AAnchorB,spacing_ring,PAnchorB,DuctLength,"
                                                + "tensioning_length,AAnchorReserve,Thickness_block,AAnchorF3,Reserved_length,Length)" +
                                       "values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}')", title.Replace("RAMP ", ""), dicP.Keys.ToList()[m], dr["No"]
                                       , dr["CurveLength"], dr["StraightLength"], dr["TheoricalLength"], dr["AAnchorB"], dr["0.02"], dr["PAnchorB"], dr["DuctLength"], dr["0.2"],
                                       dr["AAnchorReserve"], dr["0.020"], dr["AAnchorF"], dr["0.2000"], dr["Length"]);
                                            sqlList.Add(sqlT);
                                        }
                                    }

                                }
                                MySqlHelper.ExecuteNonQuery(sqlList);
                                string del = string.Format("delete from t_procedureoutinfo where pier_number='{0}' and location='{1}'and submite_position='{2}'", columnNo[i], title.Replace("RAMP ", ""), "CBT");
                                MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                                sql = string.Format("insert into t_procedureoutinfo(location,submite_position,pier_number,type,page_count)" +
                                    "values ('{0}','{1}','{2}','{3}','{4}')", title.Replace("RAMP ", ""), "CBT", columnNo[i], frm.type, pageCount);
                                MySqlHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text);

                               
                            }
                            catch { }
                            if (etype.ToString() == "BPTM1" || etype.ToString() == "BPTM1S" || etype.ToString() == "BPTM2" || etype.ToString() == "BPTE3")
                                _scale = 12.5;
                            else if (etype.ToString() == "BPTM3S" || etype.ToString() == "BPTM2S")
                                _scale = 10;
                            PlotCrossBeamTable.DrawingCapBeamRebarNew(db, path, l, frm.type, _scale, fsdTK);
                            Extensions.SaveActiveDrawing(db, pierName + "_" + frm.type + "_盖梁钢筋" + DateTime.Now.ToString("yyyyMMdd"));
                        }
                        else
                        {
                            Extensions.SaveActiveDrawing(db, pierName + "_" + frm.type + "_盖梁钢筋" + DateTime.Now.ToString("yyyyMMdd"));
                        }
                        i++;
                    }

                    if (dt.Rows.Count > 0)
                    {
                        new ExcelHelper().PrestressDataTableToExcel(dt, CurPaht.curPaht + @"OUTDWG\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "预应力量表" + DateTime.Now.ToString("yyyyMMdd") + ".xlsx");
                    }
                }
                catch (System.Exception ex)
                {
                    return;
                }
            }

        }
        #endregion

        #region 盖梁预应力
        [CommandMethod("PlotCrossBeamListTable")]
        public static void PlotCrossBeamListTable()
        {
            //去掉清楚模型空间
            //Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            BatchBeamPlotForm frm = new BatchBeamPlotForm();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {

                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    string title = frm.title;
                    string[] beams = frm.beamParas.Split(',');
                    List<string> columnNo = new List<string>(); //{ "P-316", "P-317", "P-318", "P-319", "P-320", "P-321", "P-322", "P-323", "P-324" };
                    List<int> beamLength = new List<int>(); //{ 18257, 18257, 17757, 17757, 17757, 17757, 17757, 17757, 17540 };
                    for (int m = 0; m < beams.Length; m++)
                    {
                        string cN = beams[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[0];
                        string cNH = beams[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[1];
                        columnNo.Add(cN);
                        beamLength.Add(int.Parse(cNH));
                    }

                    Type T = getObjectType(CurPaht.curPaht + @"FDEE.Model.dll", frm.type);
                    ECrossBeamType etype = (ECrossBeamType)Enum.Parse(typeof(ECrossBeamType), frm.type, true);
                    int num = 0;
                    TendonCollection reberList = new TendonCollection();
                    int OverAllScale = 1;
                    int i = 0;

                    System.Data.DataTable dt = new System.Data.DataTable();
                    dt.Columns.Add("Num", System.Type.GetType("System.String"));
                    dt.Columns.Add("PierNo", System.Type.GetType("System.String"));
                    dt.Columns.Add("No", System.Type.GetType("System.String"));
                    dt.Columns.Add("CurveLength", System.Type.GetType("System.String"));
                    dt.Columns.Add("StraightLength", System.Type.GetType("System.String"));
                    dt.Columns.Add("TheoricalLength", System.Type.GetType("System.String"));
                    dt.Columns.Add("AAnchorB", System.Type.GetType("System.String"));
                    dt.Columns.Add("0.02", System.Type.GetType("System.String"));
                    dt.Columns.Add("PAnchorB", System.Type.GetType("System.String"));
                    dt.Columns.Add("DuctLength", System.Type.GetType("System.String"));
                    dt.Columns.Add("0.2", System.Type.GetType("System.String"));
                    dt.Columns.Add("AAnchorReserve", System.Type.GetType("System.String"));
                    dt.Columns.Add("0.020", System.Type.GetType("System.String"));
                    dt.Columns.Add("AAnchorF", System.Type.GetType("System.String"));
                    dt.Columns.Add("0.2000", System.Type.GetType("System.String"));
                    dt.Columns.Add("Length", System.Type.GetType("System.String"));
                    dt.Columns.Add("fpj", System.Type.GetType("System.String"));
                    dt.Columns.Add("Elongation", System.Type.GetType("System.String"));
                    dt.Columns.Add("Degres", System.Type.GetType("System.String"));

                    List<MemberBase> rets = new List<MemberBase>();
                    foreach (int item in beamLength)
                    {

                        CrossbeamBase ret = FDEE.Model.MemberFactory.CreatMember(etype, item, columnNo[i]);
                        if (ret == null)
                        {
                            throw new System.Exception("数据异常");
                        }

                        if (ret == null)
                        {
                            throw new System.Exception("数据异常");
                        }

                        MemberBase reBase = ret as MemberBase;
                        reBase.PierNumber = columnNo[i];
                        rets.Add(reBase);

                        i++;
                    }
                    Extensions.ClearDatabase();
                    string path = CurPaht.curPaht + @"DWG\BeamBlock.dwg";//构造物
                    string pierName = columnNo[0] + "-" + columnNo[columnNo.Count - 1];
                    if (columnNo.Count == 1)
                        pierName = columnNo[0];
                    int pageCount = 1;
                    Dictionary<string, System.Data.DataTable> dicP = new Dictionary<string, System.Data.DataTable>();
                    PlotCrossBeamTable.DrawingCapBeamTable(db, rets, EStructure.E_CAPBEAM, path, frm.type, ref dt, ref dicP, ref pageCount, 1, title.Replace("RAMP ", ""), fsdTK);
                    Extensions.SaveActiveDrawing(db, pierName + "_" + frm.type + "盖梁预应力" + DateTime.Now.ToString("yyyyMMdd"), frm.title.Replace("RAMP", "").Replace(" ", ""));
                    List<string> sqlList = new List<string>();
                    try
                    {
                        if (dicP.Count > 0)
                        {
                            for (int m = 0; m < dicP.Count; m++)
                            {
                                string sqlT;
                                string delT = string.Format("delete from t_tendon where pier_number='{0}' and location='{1}'", dicP.Keys.ToList()[m], title.Replace("RAMP ", ""));
                                MySqlHelper.ExecuteNonQuery(delT, System.Data.CommandType.Text);

                                foreach (System.Data.DataRow dr in dt.Rows)
                                {
                                    sqlT = string.Format("insert into t_tendon(location,pier_number,no,CurveLength,StraightLength,TheoricalLength,AAnchorB,spacing_ring,PAnchorB,DuctLength,"
                                        + "tensioning_length,AAnchorReserve,Thickness_block,AAnchorF3,Reserved_length,Length)" +
                               "values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}')", title.Replace("RAMP ", ""), dicP.Keys.ToList()[m], dr["No"]
                               , dr["CurveLength"], dr["StraightLength"], dr["TheoricalLength"], dr["AAnchorB"], dr["0.02"], dr["PAnchorB"], dr["DuctLength"], dr["0.2"],
                               dr["AAnchorReserve"], dr["0.020"], dr["AAnchorF"], dr["0.2000"], dr["Length"]);
                                    sqlList.Add(sqlT);
                                }
                            }

                        }
                        MySqlHelper.ExecuteNonQuery(sqlList);
                        string del = string.Format("delete from t_procedureoutinfo where pier_number='{0}' and location='{1}'and submite_position='{2}'", pierName, title.Replace("RAMP ", ""), "CBT");
                        MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                        string sql = string.Format("insert into t_procedureoutinfo(location,submite_position,pier_number,type,page_count)" +
                            "values ('{0}','{1}','{2}','{3}','{4}')", title.Replace("RAMP ", ""), "CBT", pierName, frm.type, pageCount);
                        MySqlHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text);
                    }
                    catch { }
                    if (dt.Rows.Count > 0)
                    {
                        new ExcelHelper().PrestressDataTableToExcel(dt, CurPaht.curPaht + @"OUTDWG\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "预应力量表(" + pierName + ")" + DateTime.Now.ToString("yyyyMMdd") + ".xlsx");
                    }
                }
                catch (System.Exception ex)
                {
                    return;
                }
            }

        }
        //[CommandMethod("PlotCrossBeamListTable")]
        public static void PlotCrossBeamListTableByPier()
        {
            //去掉清楚模型空间
            //Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            BatchBeamPlotForm frm = new BatchBeamPlotForm();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {

                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    string title = frm.title;
                    string[] beams = frm.beamParas.Split(',');
                    List<string> columnNo = new List<string>(); //{ "P-316", "P-317", "P-318", "P-319", "P-320", "P-321", "P-322", "P-323", "P-324" };
                    List<int> beamLength = new List<int>(); //{ 18257, 18257, 17757, 17757, 17757, 17757, 17757, 17757, 17540 };
                    for (int m = 0; m < beams.Length; m++)
                    {
                        string cN = beams[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[0];
                        string cNH = beams[m].Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(':')[1];
                        columnNo.Add(cN);
                        beamLength.Add(int.Parse(cNH));
                    }

                    Type T = getObjectType(CurPaht.curPaht + @"FDEE.Model.dll", frm.type);
                    ECrossBeamType etype = (ECrossBeamType)Enum.Parse(typeof(ECrossBeamType), frm.type, true);
                    int num = 0;
                    //TendonCollection reberList = new TendonCollection();
                    int OverAllScale = 1;
                    int i = 0;

                    System.Data.DataTable dt = new System.Data.DataTable();
                    dt.Columns.Add("Num", System.Type.GetType("System.String"));
                    dt.Columns.Add("PierNo", System.Type.GetType("System.String"));
                    dt.Columns.Add("No", System.Type.GetType("System.String"));
                    dt.Columns.Add("CurveLength", System.Type.GetType("System.String"));
                    dt.Columns.Add("StraightLength", System.Type.GetType("System.String"));
                    dt.Columns.Add("TheoricalLength", System.Type.GetType("System.String"));
                    dt.Columns.Add("AAnchorB", System.Type.GetType("System.String"));
                    dt.Columns.Add("0.02", System.Type.GetType("System.String"));
                    dt.Columns.Add("PAnchorB", System.Type.GetType("System.String"));
                    dt.Columns.Add("DuctLength", System.Type.GetType("System.String"));
                    dt.Columns.Add("0.2", System.Type.GetType("System.String"));
                    dt.Columns.Add("AAnchorReserve", System.Type.GetType("System.String"));
                    dt.Columns.Add("0.020", System.Type.GetType("System.String"));
                    dt.Columns.Add("AAnchorF", System.Type.GetType("System.String"));
                    dt.Columns.Add("0.2000", System.Type.GetType("System.String"));
                    dt.Columns.Add("Length", System.Type.GetType("System.String"));
                    dt.Columns.Add("fpj", System.Type.GetType("System.String"));
                    dt.Columns.Add("Elongation", System.Type.GetType("System.String"));
                    dt.Columns.Add("Degres", System.Type.GetType("System.String"));

                    List<MemberBase> rets = new List<MemberBase>();
                    foreach (int item in beamLength)
                    {
                        rets = new List<MemberBase>();
                        Extensions.ClearDatabase();
                        CrossbeamBase ret = FDEE.Model.MemberFactory.CreatMember(etype, item, columnNo[i]);
                        if (ret == null)
                        {
                            throw new System.Exception("数据异常");
                        }

                        if (ret == null)
                        {
                            throw new System.Exception("数据异常");
                        }

                        MemberBase reBase = ret as MemberBase;
                        reBase.PierNumber = columnNo[i];
                        rets.Add(reBase);
                        Extensions.ClearDatabase();
                        string path = CurPaht.curPaht + @"DWG\BeamBlock.dwg";//构造物
                        //string pierName = columnNo[0] + "-" + columnNo[columnNo.Count - 1];
                        //if (columnNo.Count == 1)
                        //    pierName = columnNo[0];
                        int pageCount = 1;
                        Dictionary<string, System.Data.DataTable> dicP = new Dictionary<string, System.Data.DataTable>();
                        PlotCrossBeamTable.DrawingCapBeamTable(db, rets, EStructure.E_CAPBEAM, path, frm.type, ref dt, ref dicP, ref pageCount, 1, title.Replace("RAMP ", ""), fsdTK);
                        Extensions.SaveActiveDrawing(db, columnNo[i] + "_" + frm.type + "盖梁预应力" + DateTime.Now.ToString("yyyyMMdd"));
                        List<string> sqlList = new List<string>();
                        try
                        {
                            if (dicP.Count > 0)
                            {
                                for (int m = 0; m < dicP.Count; m++)
                                {
                                    string sqlT;
                                    string delT = string.Format("delete from t_tendon where pier_number='{0}' and location='{1}'", dicP.Keys.ToList()[m], title.Replace("RAMP ", ""));
                                    MySqlHelper.ExecuteNonQuery(delT, System.Data.CommandType.Text);

                                    foreach (System.Data.DataRow dr in dt.Rows)
                                    {
                                        sqlT = string.Format("insert into t_tendon(location,pier_number,no,CurveLength,StraightLength,TheoricalLength,AAnchorB,spacing_ring,PAnchorB,DuctLength,"
                                            + "tensioning_length,AAnchorReserve,Thickness_block,AAnchorF3,Reserved_length,Length)" +
                                   "values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}')", title.Replace("RAMP ", ""), dicP.Keys.ToList()[m], dr["No"]
                                   , dr["CurveLength"], dr["StraightLength"], dr["TheoricalLength"], dr["AAnchorB"], dr["0.02"], dr["PAnchorB"], dr["DuctLength"], dr["0.2"],
                                   dr["AAnchorReserve"], dr["0.020"], dr["AAnchorF"], dr["0.2000"], dr["Length"]);
                                        sqlList.Add(sqlT);
                                    }
                                }

                            }
                            MySqlHelper.ExecuteNonQuery(sqlList);
                            string del = string.Format("delete from t_procedureoutinfo where pier_number='{0}' and location='{1}'and submite_position='{2}'", columnNo[i], title.Replace("RAMP ", ""), "CBT");
                            MySqlHelper.ExecuteNonQuery(del, System.Data.CommandType.Text);
                            string sql = string.Format("insert into t_procedureoutinfo(location,submite_position,pier_number,type,page_count)" +
                                "values ('{0}','{1}','{2}','{3}','{4}')", title.Replace("RAMP ", ""), "CBT", columnNo[i], frm.type, pageCount);
                            MySqlHelper.ExecuteNonQuery(sql, System.Data.CommandType.Text);
                        }
                        catch { }

                        i++;
                    }

                    if (dt.Rows.Count > 0)
                    {
                        new ExcelHelper().PrestressDataTableToExcel(dt, CurPaht.curPaht + @"OUTDWG\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "预应力量表" + DateTime.Now.ToString("yyyyMMdd") + ".xlsx");
                    }

                }
                catch (System.Exception ex)
                {
                    return;
                }
            }

        }
        #endregion

        #region 垫石
        [CommandMethod("PlotPlinthTable")]
        public static void PlotPlinthCTable()
        {
            //去掉清楚模型空间
            //Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            SelectFileForm frm = new SelectFileForm();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {

                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    string filepath = frm.fileName;
                    string title = frm.title;
                    string path = CurPaht.curPaht + @"DWG\plinth.dwg";//构造物
                    Extensions.ClearDatabase();
                    PlotPlinthTable.DrawPlinthTable(db, 1, path, filepath, title, fsdTK);
                    Extensions.SaveActiveDrawing(db, title + "垫石坐标" + DateTime.Now.ToString("yyyyMMdd"), frm.title.Replace("RAMP", "").Replace(" ", ""));
                }
                catch (System.Exception ex)
                {
                    return;
                }
            }

        }

        [CommandMethod("PlotPlinthDepthTable")]
        public static void PlotPlinthDepthTable()
        {
            //去掉清楚模型空间
            //Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            SelectFileForm frm = new SelectFileForm();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {

                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    string filepath = frm.fileName;
                    string title = frm.title;
                    string para = frm.pierParas;
                    string path = CurPaht.curPaht + @"DWG\plinth.dwg";//构造物
                    Extensions.ClearDatabase();
                    string[] pierL = para.Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(',');
                    string pierDiv = pierL[0] + "-" + pierL[pierL.Length - 1];
                    PlotPlinthTable.DrawPlinthDepthTable(db, 1, path, filepath, para, ref pierDiv, title, fsdTK);
                    Extensions.SaveActiveDrawing(db, title + "垫石信息(" + pierDiv + ")" + DateTime.Now.ToString("yyyyMMdd"), frm.title.Replace("RAMP", "").Replace(" ", ""));
                }
                catch (System.Exception ex)
                {
                    return;
                }
            }

        }
        #endregion

        #region 挡块
        /// <summary>
        /// 挡块坐标
        /// </summary>
        [CommandMethod("PlotPlinthBlockTable")]
        public static void PlotPlinthBlockTable()
        {
            //去掉清楚模型空间
            //Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();

            try
            {
                string path = CurPaht.curPaht + @"DWG\plinth.dwg";//构造物
                Extensions.ClearDatabase();
                PlotPlinthTable.DrawPlinthBlockTable(db, 1, path);
                Extensions.SaveActiveDrawing(db, "PlinthBlock" + DateTime.Now.ToString("yyyyMMdd"));
            }
            catch (System.Exception ex)
            {
                return;
            }

        }

        /// <summary>
        /// T梁挡块高度
        /// </summary>
        [CommandMethod("PlotPlinthBlockDepthTable")]
        public static void PlotPlinthBlockDepthTable()
        {
            //去掉清楚模型空间
            //Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();

            //try
            //{
            //    System.Data.DataTable dt = new System.Data.DataTable();
            //    dt.Columns.Add("序号", System.Type.GetType("System.String"));
            //    dt.Columns.Add("墩号", System.Type.GetType("System.String"));
            //    dt.Columns.Add("橡胶支座厚度", System.Type.GetType("System.String"));
            //    dt.Columns.Add("Side", System.Type.GetType("System.String"));
            //    dt.Columns.Add("挡块编号", System.Type.GetType("System.String"));
            //    dt.Columns.Add("垫石高度", System.Type.GetType("System.String"));
            //    dt.Columns.Add("纵坡", System.Type.GetType("System.String"));
            //    dt.Columns.Add("楔形块中心厚度", System.Type.GetType("System.String"));
            //    dt.Columns.Add("挡块高度", System.Type.GetType("System.String"));

            //    string path = CurPaht.curPaht + @"DWG\plinth.dwg";//构造物
            //    Extensions.ClearDatabase();
            //    PlotPlinthTable.DrawPlinthBlockDepthTable(db, 1, path,ref dt);
            //    Extensions.SaveActiveDrawing(db, "挡块高度" + DateTime.Now.ToString("yyyyMMdd"));

            //    new ExcelHelper().TableToExcelForXLS(dt, CurPaht.curPaht + @"DWG\挡块高度.xls");
            //}
            //catch (System.Exception ex)
            //{
            //    return;
            //}
            //);
            BufferDepthForm frm = new BufferDepthForm(true);
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    System.Data.DataTable dt = new System.Data.DataTable();
                    dt.Columns.Add("序号", System.Type.GetType("System.String"));
                    dt.Columns.Add("墩号", System.Type.GetType("System.String"));
                    dt.Columns.Add("橡胶支座厚度", System.Type.GetType("System.String"));
                    dt.Columns.Add("Side", System.Type.GetType("System.String"));
                    dt.Columns.Add("挡块编号", System.Type.GetType("System.String"));
                    dt.Columns.Add("垫石高度", System.Type.GetType("System.String"));
                    dt.Columns.Add("纵坡", System.Type.GetType("System.String"));
                    dt.Columns.Add("楔形块中心厚度", System.Type.GetType("System.String"));
                    dt.Columns.Add("挡块高度", System.Type.GetType("System.String"));

                    //string dwgpath = CurPaht.curPaht + @"DWG\plinth.dwg";//构造物
                    string dwgpath = CurPaht.curPaht + @"DWG\BeamBlock.dwg";//构造物
                    Extensions.ClearDatabase();
                    string pierdiv = "";
                    PloterBufferTable.DrawTBlockDepthTable(db, 1, dwgpath, ref dt, frm.filePlinthName, frm.fileBeamParaName, frm.piersString, frm.TAParas, frm.TBParas, ref pierdiv, frm.title, fsdTK);
                    Extensions.SaveActiveDrawing(db, frm.title + "T梁挡块钢筋及高度(" + pierdiv + ")" + DateTime.Now.ToString("yyyyMMdd"), frm.title.Replace("RAMP", "").Replace(" ", ""));

                    //new ExcelHelper().TableToExcelForXLS(dt, CurPaht.curPaht + @"DWG\挡块高度.xls");
                }
                catch (System.Exception ex)
                {
                    return;
                }
            }
        }

        /// <summary>
        /// I梁挡块高度
        /// </summary>
        [CommandMethod("PlotBlockDepthTable")]
        public static void PlotBlockDepthTable()
        {
            //去掉清楚模型空间
            Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            BufferDepthForm frm = new BufferDepthForm(false);
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                try
                {

                    System.Data.DataTable dt = new System.Data.DataTable();
                    dt.Columns.Add("PierNo", System.Type.GetType("System.String"));
                    dt.Columns.Add("Station", System.Type.GetType("System.String"));
                    dt.Columns.Add("H", System.Type.GetType("System.String"));
                    dt.Columns.Add("L", System.Type.GetType("System.String"));
                    dt.Columns.Add("Angle", System.Type.GetType("System.String"));

                    string dwgpath = CurPaht.curPaht + @"DWG\plinth.dwg";//构造物
                    Extensions.ClearDatabase();
                    string pierdiv = "";
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    PloterBufferTable.DrawBlockDepthTable(db, 1, dwgpath, ref dt, frm.filePlinthName, frm.fileBeamParaName, frm.piersString, frm.IAParas, frm.IBParas, frm.TAParas, frm.TBParas, ref pierdiv, fsdTK);
                    Extensions.SaveActiveDrawing(db, frm.title.Replace("RAMP", "") + "I梁挡块高度(" + pierdiv + ")" + DateTime.Now.ToString("yyyyMMdd"), frm.title.Replace("RAMP", "").Replace(" ", ""));

                    new ExcelHelper().DataTableToExcel(dt, CurPaht.curPaht + @"OUTDWG\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "I梁挡块高度(" + pierdiv + ").xlsx");
                }
                catch (System.Exception ex)
                {
                    return;
                }
            }

        }
        //I梁档块钢筋
        [CommandMethod("PlotBlockRebarTable")]
        public static void PlotBlockRebarTable()
        {
            //去掉清楚模型空间
            Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            SelectFileForm frm = new SelectFileForm();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    System.Data.DataTable dt = new System.Data.DataTable();

                    string filepath = frm.fileName;
                    string title = frm.title;
                    System.IO.FileInfo file = new FileInfo(filepath);
                    if (file.Extension.Contains("xlsx"))
                        dt = new FDEECommonTools.ExcelHelper().ExcelToTableForXLSX(filepath);
                    else
                        dt = FDEECommonTools.CVSTools.OpenCSV(filepath);
                    string dwgpath = CurPaht.curPaht + @"DWG\BeamBlock.dwg";//构造物
                    Extensions.ClearDatabase();
                    string pierdiv = "";
                    DrawingBufferTable.DrawIBlockDepthTable(db, 1, dwgpath, dt, ref pierdiv, title, fsdTK);
                    Extensions.SaveActiveDrawing(db, frm.title.Replace("RAMP", "") + "I梁挡块钢筋(" + pierdiv + ")" + DateTime.Now.ToString("yyyyMMdd"), frm.title.Replace("RAMP", "").Replace(" ", ""));

                    //new ExcelHelper().TableToExcelForXLS(dt, CurPaht.curPaht + @"DWG\挡块高度.xls");
                }
                catch (System.Exception ex)
                {
                    return;
                }
            }

        }
        #endregion 

        #region 盖梁构造图
        /// <summary>
        /// 盖梁构造图绘制
        /// </summary>
        [CommandMethod("PlotBatchPlinth")]
        public static void PlotBeamPlinth()
        {
            //去掉清楚模型空间
            Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            BufferStructureForm frm = new BufferStructureForm();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    string path = CurPaht.curPaht + @"DWG\plinth.dwg";//构造物
                    string pierdiv = "";
                    DrawingPlinthList.DrawPlinthBatch(db, path, frm.filePlinthName, frm.fileBeamParaName, frm.stNum, frm.endNum, frm.piersString, frm.TAParas, frm.TBParas, frm.IAParas, frm.IBParas, ref pierdiv, frm.title);
                    Extensions.SaveActiveDrawing(db, frm.title.Replace("RAMP", "") + "_盖梁构造(" + pierdiv + ")" + DateTime.Now.ToString("yyyyMMdd"), frm.title.Replace("RAMP", "").Replace(" ", ""));

                }
                catch (System.Exception ex)
                {
                    return;
                }
            }

        }


        /// <summary>
        /// 匝道盖梁构造图绘制
        /// </summary>
        [CommandMethod("PlotBatchRampPlinth")]
        public static void PlotRampBeamPlinth()
        {
            //去掉清楚模型空间
            Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            BufferStructureForm frm = new BufferStructureForm();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    string path = CurPaht.curPaht + @"DWG\plinth.dwg";//构造物
                    string pierdiv = "";
                    DrawingRampPlinthList.DrawRampPlinthBatch(db, path, frm.filePlinthName, frm.fileBeamParaName, frm.stNum, frm.endNum, frm.piersString, frm.TAParas, frm.TBParas, frm.IAParas, frm.IBParas, ref pierdiv, frm.title, fsdTK, frm.isPositive);
                    Extensions.SaveActiveDrawing(db, frm.title.Replace("RAMP", "") + "_盖梁构造(" + pierdiv + ")" + DateTime.Now.ToString("yyyyMMdd"), frm.title.Replace("RAMP", "").Replace(" ", ""));

                }
                catch (System.Exception ex)
                {
                    return;
                }
            }

        }
        #endregion

        #region 平面信息表
        [CommandMethod("PlotLineInformationTable")]
        public static void PlotLineInformationTable()
        {
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            SelectFileForm frm = new SelectFileForm();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {

                try
                {
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + frm.title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    string filepath = frm.fileName;
                    string title = frm.title;
                    string para = frm.pierParas;
                    string path = CurPaht.curPaht + @"DWG\plinth.dwg";//构造物
                    Extensions.ClearDatabase();
                    string[] pierL = para.Replace("(","").Replace(")", "").Replace("（", "").Replace("）", "").Split(',');
                    string pierDiv = pierL[0] + "-" + pierL[pierL.Length - 1];
                    PlotLineInfomationTable.DrawBeamLineInfomationTable(db, 1, path, filepath, para, ref pierDiv, title, fsdTK);
                    Extensions.SaveActiveDrawing(db, title + "垫石信息(" + pierDiv + ")" + DateTime.Now.ToString("yyyyMMdd"), frm.title.Replace("RAMP", "").Replace(" ", ""));
                }
                catch (System.Exception ex)
                {
                    return;
                }
            }

        }
        #endregion

        #region 其他通用方法
        private static Type getObjectType(string dllFile, string objFullName)
        {
            Type type = Assembly.LoadFile(dllFile).GetType("FDEE.Model." + objFullName);
            if (type != null)
            {
                Console.WriteLine("find obj in dll[" + dllFile + "]");
                return type;
            }
            return null;
        }
        #endregion

        #region 测试
        /// <summary>
        /// 匝道盖梁构造图绘制
        /// </summary>
        [CommandMethod("Test")]
        public static void GetInfoAndCoordinates()
        {
            //去掉清楚模型空间
            Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------


            try
            {
                string dwgFile = @"C:\Users\huajie\Documents\WXWork\1688856441293541\Cache\File\2022-03\最新布梁图 2022.03.03\XRef_DEEP2_NEW PIER ARRANGEMENT_20210604_Final-（梁长 2022.2.20最新).dwg";//构造物


                string dir = System.IO.Path.GetDirectoryName(dwgFile);   //文件路径
                string fileName = System.IO.Path.GetFileNameWithoutExtension(dwgFile);  //文件名称
                Document _doc = Application.DocumentManager.MdiActiveDocument;
                Autodesk.AutoCAD.Interop.AcadApplication acadApp = (Autodesk.AutoCAD.Interop.AcadApplication)Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
                //acadApp.Documents.Close();
                AcadDocument acadDoc = acadApp.Documents.Open(dwgFile);

                Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
                //Autodesk.Autocad.ApplicationServices.Document
                Database db = doc.Database;//Autodesk.Autocad.ApplicationServices.Database
                Editor ed = doc.Editor;//Autodesk.Autocad.EditorInput.Editor
                DocumentLock docLock = doc.LockDocument();

                //using (Transaction trans = db.TransactionManager.StartTransaction())
                //{
                //    BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForWrite);
                //    foreach (ObjectId btrid in bt)
                //    {
                //        //Entity ent = trans.GetObject(eid, OpenMode.ForWrite) as Entity;
                //        //if (ent is BlockReference)
                //        //{
                //        //    if (ent.XData != null && ent.XData.AsArray()[0].Value.ToString() == XDataAppName.XDataAppName_POINT)
                //        //    {
                //        //        BlockReference blockRef = ent as BlockReference;

                //        //    }
                //        //    else
                //        //    {
                //        //        BlockReference blockRef = ent as BlockReference;

                //        //    }
                //        //}
                //    }
                //    //trans.Commit();
                //}


                acadApp.ZoomExtents();//将当前视图居中显示
                acadDoc.Save();//保存当前视图
                //acadDoc.Close("TRUE", acadDoc.FullName);//关闭视图
            }
            catch (System.Exception ex)
            {
                return;
            }
        }
        [CommandMethod("ReadDwgFileTest")]
        public static void ReadDwgFileTest()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;

            using (Database db = new Database(false, true))
            {
                try
                {
                    // 读取dwg文件
                    string dwgFileFullPath = @"C:\Users\huajie\Documents\WXWork\1688856441293541\Cache\File\2022-03\XRef_DEEP2_NEW PIER ARRANGEMENT_20210604_Final-（梁长 2022.2.20最新).dwg";//构造物

                    db.ReadDwgFile(dwgFileFullPath,
                        FileOpenMode.OpenForReadAndAllShare, false, "");
                    db.CloseInput(true);
                }
                catch (System.Exception ex)
                {
                    doc.Editor.WriteMessage("\nUnable to read drawing file.");
                    return;
                }

                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    // 模型空间
                    //BlockTable blkTbl = tr.GetObject(db.BlockTableId, OpenMode.ForRead)
                    //    as BlockTable;
                    //BlockTableRecord modelSpace = tr.GetObject(
                    //    blkTbl[BlockTableRecord.ModelSpace], OpenMode.ForRead)
                    //    as BlockTableRecord;

                    //// 遍历模型空间
                    //foreach (ObjectId oid in modelSpace)
                    //{
                    //    DBObject dbobj = tr.GetObject(oid, OpenMode.ForRead);
                    //    if (dbobj is Entity)
                    //    {
                    //        Entity entity = dbobj as Entity;
                    //        doc.Editor.WriteMessage("\nEntity: {0}, {1}, {2}, {3}",
                    //            entity.Id,
                    //            entity.GetType().ToString(),
                    //            entity.Layer,
                    //            entity.Color.ToString());
                    //    }
                    //}
                }
            }
        }
        #endregion

        #region 桥面板信息测试
        //[CommandMethod("PlotDeckSlabTable")]
        public static void PlotDeckSlabTable()
        {
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            string title = "MAINLINE";//线路名称
            try
            {
                string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                string savePath = CurPaht.curPaht + "OUTDWG\\" + title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                if (!System.IO.File.Exists(savePath))
                {
                    FileInfo fileTK = new FileInfo(savePath);

                    if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                    {
                        //创建文件夹
                        System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                    }
                    //复制图框
                    System.IO.File.Copy(fsdTK, savePath, true);
                }
                //去掉清楚模型空间
                Extensions.ClearDatabase();
                //模板数据路径
                string filepath = @"C:\Users\huajie\Documents\WXWork\1688856441293541\Cache\File\2022-04\FDEE(1).csv";
                string pierDiv = "";
                //绘制桥面板
                PLotDeckSlabTable.DrawDeckSlabTable(db, 1, filepath, ref pierDiv, title, fsdTK);
                //保存位置
                Extensions.SaveActiveDrawing(db, title + "桥面板" + DateTime.Now.ToString("yyyyMMdd"), title.Replace("RAMP", "").Replace(" ", ""));
            }
            catch (System.Exception ex)
            {
                return;
            }


        }
        [CommandMethod("PlotDeckSlabTable")]
        public static void PlotDeckSlabTableNew()
        {
            //去掉清楚模型空间

            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            string title = "MAINLINE";//线路名称
            try
            {
                SelectFileForm frm = new SelectFileForm();
                frm.ShowDialog();
                if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    string filepath = frm.fileName;
                    title = frm.title;
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            //创建文件夹
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }
                        //复制图框
                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    //去掉清楚模型空间
                    Extensions.ClearDatabase();
                    //模板数据路径
                    //string filepath = @"C:\Users\huajie\Documents\WXWork\1688856441293541\Cache\File\2022-04\FDEE.csv";
                    string pierDiv = "";
                    //绘制桥面板
                    PLotDeckSlabTable.DrawDeckSlabTable(db, 1, filepath, ref pierDiv, title, fsdTK);
                    //保存位置
                    Extensions.SaveActiveDrawing(db, title + "桥面板" + DateTime.Now.ToString("yyyyMMdd"), title.Replace("RAMP", "").Replace(" ", ""));
                }
            }
            catch (System.Exception ex)
            {
                return;
            }


        }

        //T梁现浇板
        [CommandMethod("PlotDeckSlabRebarTable")]
        public static void PlotDeckSlabRebarTable()
        {
            //去掉清楚模型空间

            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            string title = "MAINLINE";//线路名称
            try
            {
                DeckSlabParaForm frm = new DeckSlabParaForm();
                frm.ShowDialog();
                if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                {

                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            //创建文件夹
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }
                        //复制图框
                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    //去掉清楚模型空间
                    Extensions.ClearDatabase();
                    string path = CurPaht.curPaht + @"DWG\SpanBlock.dwg";//构造物
                    TDeckSlab ret = new TDeckSlab("", "", (int)frm.width, (int)frm.length, frm.NumHalfEJ, frm.NumLink,frm.NumHole);
                    ret.SetRebarList();
                    ret.SetConcreteVolume();
                    ret.SetConcreteClass();
                    MemberBase reBase = ret as MemberBase;
                    title = frm.title;
                    if (ret.RebarList != null && ret.RebarList.Count > 0)
                    {
                        //绘制桥面板钢筋
                        PlotRCPlatTable.DrawingDeckSlabTable(db, reBase, path, frm.pierParas, frm.eHeightType, 1, title, fsdTK, true);
                        //保存位置
                        Extensions.SaveActiveDrawing(db, title + "T梁现浇板(" + frm.pierParas + ")" + DateTime.Now.ToString("yyyyMMdd"), title.Replace("RAMP", "").Replace(" ", ""));
                    }
                }
            }
            catch (System.Exception ex)
            {
                return;
            }


        }
        //混凝土预制板
        //[CommandMethod("PlotRCPlatRebarTable")]
        public static void PlotRCPlatRebarTable()
        {
            //去掉清楚模型空间

            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            string title = "MAINLINE";//线路名称
            try
            {
                DeckSlabParaForm frm = new DeckSlabParaForm(false);
                frm.ShowDialog();
                if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                {

                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            //创建文件夹
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }
                        //复制图框
                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    //去掉清楚模型空间
                    Extensions.ClearDatabase();
                    string path = CurPaht.curPaht + @"DWG\SpanBlock.dwg";//构造物
                    PlateBase ret = new RCPlate("", "", (int)frm.width, frm.eHeightType, frm.hasHole);
                    ret.SetRebarList();
                    ret.SetConcreteVolume();
                    ret.SetConcreteClass();
                    MemberBase reBase = ret as MemberBase;
                    if (ret.RebarList != null && ret.RebarList.Count > 0)
                    {
                        //绘制混凝土预制板钢筋
                        PlotRCPlatTable.DrawingRCPlatTable(db, reBase, path, frm.pierParas, frm.eHeightType, frm.typeNum, (int)frm.width, 1, title, fsdTK);
                        PlotRCPlatTable.DrawListMergeTable(db, reBase, Point2d.Origin.Convert3D(0, 297), Extensions.curFont, 1, frm.eHeightType, frm.typeNum, (int)frm.width, frm.totalNum, title);
                        //保存位置
                        Extensions.SaveActiveDrawing(db, title + "混凝土预制板(" + frm.eHeightType.ToString() + "-" + frm.typeNum + "(L=" + frm.width * 0.001 + "))" + DateTime.Now.ToString("yyyyMMdd"), title.Replace("RAMP", "").Replace(" ", ""));
                    }
                }
            }
            catch (System.Exception ex)
            {
                return;
            }


        }
        [CommandMethod("PlotRCPlatRebarTable")]
        public static void BatchPlotRCPlatRebarTable()
        {
            //去掉清楚模型空间

            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            string title = "MAINLINE";//线路名称
            try
            {
                SelectFileForm frm = new SelectFileForm();
                frm.ShowDialog();
                if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    title = frm.title;
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            //创建文件夹
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }
                        //复制图框
                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    //去掉清楚模型空间
                    Extensions.ClearDatabase();
                    string filepath = frm.fileName;
                    string path = CurPaht.curPaht + @"DWG\SpanBlock.dwg";//构造物
                    int width = 0, typeNum = 1, totalNum = 1;
                    FDEE.Model.eSubType eHeightType = FDEE.Model.eSubType.A;
                    bool hasHole = false;
                    System.IO.FileInfo file = new FileInfo(filepath);
                    System.Data.DataTable dt = new System.Data.DataTable();
                    if (file.Extension.Contains("xlsx"))
                        dt = new FDEECommonTools.ExcelHelper().ExcelToTableForXLSX(filepath);
                    else
                        dt = FDEECommonTools.CVSTools.OpenCSV(filepath);
                    if (dt.Rows.Count > 0)
                    {
                        List<MemberBase> rets = new List<MemberBase>();
                        List<int> LLst = new List<int>();
                        string pierDiv = frm.pierParas;
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            System.Data.DataRow dr = dt.Rows[i];
                            width = (int)(double.Parse(dr["L"].ToString()) * 1000);

                            string type = dr["PanelNumber"].ToString();
                            int num = int.Parse(dr["PanelNO"].ToString());
                            typeNum = int.Parse(System.Text.RegularExpressions.Regex.Replace(type, @"[^0-9]+", ""));
                            eHeightType = (FDEE.Model.eSubType)Enum.Parse(typeof(FDEE.Model.eSubType), type.Substring(0, 1));
                            PlateBase ret = new RCPlate("", "", width, eHeightType, hasHole);
                            ret.SetRebarList();
                            ret.SetConcreteVolume();
                            ret.SetConcreteClass();
                            ret.Count = num;
                            ret.TypeName = type;
                            rets.Add(ret);
                            LLst.Add(width);
                            MemberBase reBase = ret as MemberBase;
                            if (ret.RebarList != null && ret.RebarList.Count > 0)
                            {
                                //绘制混凝土预制板钢筋
                                PlotRCPlatTable.DrawingRCPlatTable(db, reBase, path, frm.pierParas, eHeightType, typeNum, width, 1, title, fsdTK, i);
                            }
                        }
                        if (rets.Count > 0)
                        {
                            PlotRCPlatTable.DrawListMergeTable(db, rets, LLst, Point2d.Origin.Convert3D(0, 297), Extensions.curFont, 1, title, pierDiv, -1, fsdTK);
                        }
                        //保存位置
                        Extensions.SaveActiveDrawing(db, title + "混凝土预制板(" + frm.pierParas + ")" + DateTime.Now.ToString("yyyyMMdd"), title.Replace("RAMP", "").Replace(" ", ""));
                    }
                }
            }
            catch (System.Exception ex)
            {
                return;
            }


        }
        //I梁三角区
        [CommandMethod("PlotSCPlatRebarTable")]
        public static void BatchPlotSCPlatRebarTable()
        {
            //去掉清楚模型空间

            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            string title = "MAINLINE";//线路名称
            try
            {
                SelectFileForm frm = new SelectFileForm();
                frm.ShowDialog();
                if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    title = frm.title;
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            //创建文件夹
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }
                        //复制图框
                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    //去掉清楚模型空间
                    Extensions.ClearDatabase();
                    string filepath = frm.fileName;
                    string path = CurPaht.curPaht + @"DWG\SpanBlock.dwg";//构造物
                    int width1 = 0, width2 = 0, L = 0;
                    FDEE.Model.eSubType eHeightType = FDEE.Model.eSubType.A;
                    bool hasHole = false;
                    System.IO.FileInfo file = new FileInfo(filepath);
                    System.Data.DataTable dt = new System.Data.DataTable();
                    if (file.Extension.Contains("xlsx"))
                        dt = new FDEECommonTools.ExcelHelper().ExcelToTableForXLSX(filepath);
                    else
                        dt = FDEECommonTools.CVSTools.OpenCSV(filepath);
                    if (dt.Rows.Count > 0)
                    {
                        //string _blcName = "ISA";
                        //db.CopyBlockFromFile(path, _blcName);
                        //Extents2d ext = new Extents2d(Point2d.Origin.Convert2D(0, 297), Point2d.Origin.Convert2D(0, 297));
                        //BlockTool.InsertBlockReference(Point2d.Origin.Convert3D(0, 297), 25, _blcName, path, null, null, ref ext);
                        //Common.CreateLayoutNew(db, "I梁三角区", ext, 1, 1, -1, 0, false, fsdTK);
                        List<MemberBase> rets = new List<MemberBase>();
                        List<int> LLst = new List<int>();
                        string pierDiv = frm.pierParas;
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            System.Data.DataRow dr = dt.Rows[i];
                            width1 = (int)(double.Parse(dr["W1"].ToString()));
                            width2 = (int)(double.Parse(dr["W2"].ToString()));
                            L = (int)(double.Parse(dr["L"].ToString()));
                            string type = dr["PanelNumber"].ToString();
                            //int num = int.Parse(dr["PanelNO"].ToString());
                            //typeNum = int.Parse(System.Text.RegularExpressions.Regex.Replace(type, @"[^0-9]+", ""));
                            //eHeightType = (FDEE.Model.eSubType)Enum.Parse(typeof(FDEE.Model.eSubType), type.Substring(0, 1));
                            SDeckSlab ret = new SDeckSlab("", "", width1, width2, L);
                            ret.SetRebarList();
                            ret.SetConcreteVolume();
                            ret.SetConcreteClass();
                            //ret.Count = num;
                            ret.TypeName = type;
                            rets.Add(ret);
                            //LLst.Add(width);
                            MemberBase reBase = ret as MemberBase;
                            if (ret.RebarList != null && ret.RebarList.Count > 0)
                            {
                                //绘制混凝土预制板钢筋
                                PlotRCPlatTable.DrawingSDeckSlabTable(db, reBase, path, frm.pierParas, type, 1, title, fsdTK, i);
                            }
                        }

                        //保存位置
                        Extensions.SaveActiveDrawing(db, title + "I梁三角区(" + frm.pierParas + ")" + DateTime.Now.ToString("yyyyMMdd"), title.Replace("RAMP", "").Replace(" ", ""));
                    }
                }
            }
            catch (System.Exception ex)
            {
                return;
            }


        }

        //I梁现浇板-圆弧段
        [CommandMethod("PlotDeckSlabCurveRebarTable")]
        public static void PlotDeckSlabCurveRebarTable()
        {
            //去掉清楚模型空间

            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            string title = "MAINLINE";//线路名称
            try
            {
                DeckSlabCurveParaForm frm = new DeckSlabCurveParaForm();
                frm.ShowDialog();
                if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    title = frm.title;
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";

                    //去掉清楚模型空间
                    Extensions.ClearDatabase();
                    title = frm.title;

                    string path = CurPaht.curPaht + @"DWG\SpanBlock.dwg";//构造物

                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            //创建文件夹
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }
                        //复制图框
                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    //去掉清楚模型空间
                    Extensions.ClearDatabase();

                    TDeckSlabCurve ret = new TDeckSlabCurve("", "", (int)frm.width, (int)frm.widthOuter, frm.span, frm.R, frm.beamWA, frm.beamWB, frm.endA, frm.endB, 1, 1, 1, 1);
                    ret.SetRebarList();
                    ret.SetConcreteVolume();
                    ret.SetConcreteClass();
                    MemberBase reBase = ret as MemberBase;
                    title = frm.title;
                    int pageCount = 0;
                    if (ret.RebarList != null && ret.RebarList.Count > 0)
                    {
                        //绘制桥面板钢筋
                        PlotRCPlatTable.DrawingTDeckSlabCurveTable(db, reBase, path, frm.pierParas, ref pageCount, 1, 1, title, fsdTK);
                        //保存位置
                        Extensions.SaveActiveDrawing(db, title + "I梁现浇板-圆弧段(" + frm.pierParas + ")" + DateTime.Now.ToString("yyyyMMdd"), title.Replace("RAMP", "").Replace(" ", ""));
                    }

                }
            }
            catch (System.Exception ex)
            {
                return;
            }


        }
        #endregion

        #region 导入excel 生成钢筋表
        
        [CommandMethod("PlotExcel2CADRebarTable")]
        public static void PlotExcel2CADRebarTable()
        {
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            string title = "MAINLINE";//线路名称
            try
            {
                SelectFileForm frm = new SelectFileForm();
                frm.ShowDialog();
                if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    title = frm.title;
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            //创建文件夹
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }
                        //复制图框
                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    //去掉清楚模型空间
                    Extensions.ClearDatabase();
                    string filepath = frm.fileName;
                    string path = CurPaht.curPaht + @"DWG\SpanBlock.dwg";//构造物
     
                    System.IO.FileInfo file = new FileInfo(filepath);
                    System.Data.DataTable dt = new System.Data.DataTable();
                    if (file.Extension.Contains("xlsx"))
                        dt = new FDEECommonTools.ExcelHelper().ExcelToTableForXLSX(filepath, "Excel2CAD");
                    else
                        dt = FDEECommonTools.CVSTools.OpenCSV(filepath);
                    if (dt.Rows.Count > 0)
                    {
                        Excel2CADRebar ret = new Excel2CADRebar("", "", dt);
                        ret.SetRebarList();
                        ret.SetConcreteVolume();
                        ret.SetConcreteClass();
                        MemberBase reBase = ret as MemberBase;
                        title = frm.title;
                        int pageCount = 0;
                        if (ret.RebarList != null && ret.RebarList.Count > 0)
                        {
                            //绘制桥面板钢筋
                            PlotRebarByExcelTable.DrawingExcel2CADRebarTable(db, reBase, path, frm.pierParas, ref pageCount, 1, 1, title, fsdTK);
                            //保存位置
                            Extensions.SaveActiveDrawing(db, title + "钢筋表(" + frm.pierParas + ")" + DateTime.Now.ToString("yyyyMMdd"), title.Replace("RAMP", "").Replace(" ", ""));
                        }

                    }
                }
            }
            catch (System.Exception ex)
            {
                return;
            }


        }
        #endregion



        #region 导入excel 护栏参数表

        [CommandMethod("PlotExcel2PositionBarrierTable")]
        public static void PlotExcel2PositionBarrierTable()
        {
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            string title = "MAINLINE";//线路名称
            try
            {
                SelectBarrierPositionFileForm frm = new SelectBarrierPositionFileForm();
                frm.ShowDialog();
                if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    title = frm.title;
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            //创建文件夹
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }
                        //复制图框
                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    //去掉清楚模型空间
                    Extensions.ClearDatabase();
                    string filepath = frm.fileName;
                    string path = CurPaht.curPaht + @"DWG\SpanBlock.dwg";//构造物

                    System.IO.FileInfo file = new FileInfo(filepath);
                    System.Data.DataTable dt = new System.Data.DataTable();
                    if (file.Extension.Contains("xlsx"))
                        dt = new FDEECommonTools.ExcelHelper().ExcelToTableForXLSX(filepath);
                    else
                        dt = FDEECommonTools.CVSTools.OpenCSV(filepath);
                    if (dt.Rows.Count > 0)
                    {
                        title = frm.title;
                        int pageCount = 0;
                        if (dt!=null&&dt.Rows.Count > 0)
                        {
                            //绘制桥面板钢筋
                            PlotBarrierPositionByExcelTable.DrawingExcel2CADTable(db, dt, path, frm.pierParas, ref pageCount, 1, 1, title, fsdTK);
                            //保存位置
                            Extensions.SaveActiveDrawing(db, title + "护栏参数表(" + frm.pierParas + ")" + DateTime.Now.ToString("yyyyMMdd"), title.Replace("RAMP", "").Replace(" ", ""));
                        }

                    }
                }
            }
            catch (System.Exception ex)
            {
                return;
            }


        }
        #endregion
        [CommandMethod("PlotRebarTable")]
        public static void PlotCADRebarTable()
        {
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();
            string title = "MAINLINE";//线路名称
            try
            {
                SelectFileForm frm = new SelectFileForm();
                frm.ShowDialog();
                if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
                {
                    title = frm.title;
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\" + title.Replace("RAMP", "").Replace(" ", "") + "\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            //创建文件夹
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }
                        //复制图框
                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    //去掉清楚模型空间
                    Extensions.ClearDatabase();
                    string filepath = frm.fileName;
                    string path = CurPaht.curPaht + @"DWG\SpanBlock.dwg";//构造物

                    System.IO.FileInfo file = new FileInfo(filepath);
                    System.Data.DataTable dt = new System.Data.DataTable();
                    if (file.Extension.Contains("xlsx"))
                        dt = new FDEECommonTools.ExcelHelper().ExcelToTableForXLSX(filepath);
                    else
                        dt = FDEECommonTools.CVSTools.OpenCSV(filepath);
                    if (dt.Rows.Count > 0)
                    {
                        List<MemberBase> rets = new List<MemberBase>();
                        List<System.Data.DataRow> drs = new List<System.Data.DataRow>();
                        foreach (System.Data.DataRow dr in dt.Rows)
                        {
                            CPileRebar ret = new CPileRebar("", "", dr);
                            ret.SetRebarList();
                            ret.SetConcreteVolume();
                            ret.SetConcreteClass();
                            MemberBase reBase = ret as MemberBase;
                            rets.Add(reBase);
                            drs.Add(dr);
                        }
                        title = frm.title;
                        int pageCount = 0;
                        if (rets != null && rets.Count > 0)
                        {
                            //绘制桥面板钢筋
                            PlotCPileRebarByExcelTable.DrawingRebarTable(db, rets, drs,path, frm.pierParas, 1, title, fsdTK);
                            //保存位置
                            Extensions.SaveActiveDrawing(db, title + "钢筋表(" + frm.pierParas + ")" + DateTime.Now.ToString("yyyyMMdd"), title.Replace("RAMP", "").Replace(" ", ""));
                        }

                    }
                }
            }
            catch (System.Exception ex)
            {
                return;
            }


        }
    }

    public class PileMaster
    {
        #region 其他通用方法
        private static Type getObjectType(string dllFile, string objFullName)
        {
            Type type = Assembly.LoadFile(dllFile).GetType("FDEE.Model." + objFullName);
            if (type != null)
            {
                Console.WriteLine("find obj in dll[" + dllFile + "]");
                return type;
            }
            return null;
        }
        #endregion
        /// <summary>
        /// 表格绘制
        /// </summary>
        //[CommandMethod("PlotPileTable")]
        //public static void PlotPileTable()
        //{
        //    //去掉清楚模型空间
        //    Extensions.ClearDatabase();
        //    //--------------------------------------------------------------------------------------
        //    // 基本句柄
        //    //--------------------------------------------------------------------------------------
        //    Document doc = Application.DocumentManager.MdiActiveDocument;
        //    Database db = doc.Database;
        //    Editor ed = doc.Editor;
        //    InitSetting.IniConfig();

        //    PileParamentForm frm = new PileParamentForm();
        //    frm.ShowDialog();
        //    if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
        //    {
        //        try
        //        {
        //            string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
        //            string savePath = CurPaht.curPaht + "OUTDWG\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
        //            if (!System.IO.File.Exists(savePath))
        //            {
        //                FileInfo fileTK = new FileInfo(savePath);

        //                if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
        //                {
        //                    System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
        //                }

        //                System.IO.File.Copy(fsdTK, savePath, true);
        //            }
        //            // FDEE.Model.FPME41.
        //            Type T = getObjectType(CurPaht.curPaht + @"FDEE.Model.dll", frm.para.type);
        //            int num = 0;

        //            RebarCollection reberList = new RebarCollection();
        //            int OverAllScale = 1;
        //            string structureName = "";
        //            FDEE.Model.eConcreteClass eConType = FDEE.Model.eConcreteClass.None;
        //            double conValue = 0;
        //            string path = "";//构造物

        //            path = CurPaht.curPaht + @"DWG\桩基块.dwg";//构造物
                
        //            PileBase ret = FDEE.Model.MemberFactory.CreatMember((EPileType)frm.pilePara.eSubType, FDEE.Model.eSubType.None, frm.pilePara.pileLength, (int)(frm.pilePara.pileDia * 1000), (int)(frm.pilePara.DOWEL));
        //            if (ret == null)
        //            {
        //                throw new System.Exception("数据异常");
        //            }
        //            MemberBase reBase = ret as MemberBase;
        //            if (ret.RebarList != null && ret.RebarList.Count > 0)
        //            {
        //                PloterTable.DrawingPileTable(db, reBase, frm.para.eType, path, frm.pilePara.type, frm.pilePara.pileLength, (int)frm.pilePara.DOWEL,
        //                    (FDEE.Model.eSubType)frm.para.nHeightType, eConType, conValue);
        //            }
        //            else
        //            {
        //                throw new System.Exception("数据异常");
        //            }



        //        }
        //        catch (System.Exception ex)
        //        {
        //            return;
        //        }
        //    }
        //}

        [CommandMethod("PlotPileTable")]
        public static void DrawingPiles()
        {
            Extensions.ClearDatabase();
            //--------------------------------------------------------------------------------------
            // 基本句柄
            //--------------------------------------------------------------------------------------
            Document doc = Application.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            InitSetting.IniConfig();

            PileRebarForm frm = new PileRebarForm();
            frm.ShowDialog();
            if (frm.DialogResult == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    //去掉清楚模型空间
                    Extensions.ClearDatabase(db);

                    try
                    {
                        db.XrefAttachAndInsertModel(frm.dwgFileName, db.CurrentSpaceId, Point3d.Origin,new Scale3d(1));                       
                    }
                    catch (System.Exception ex)
                    {
                        doc.Editor.WriteMessage("\nUnable to read drawing file.");
                        return;
                    }

                
                    string title = frm.title;
                    //string dwgPath = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string fsdTK = Extensions.curPaht + @"DWG\Title-DEEP T2&T3 (A3)_R3.dwg";
                    string savePath = CurPaht.curPaht + "OUTDWG\\DWG\\Title-DEEP T2&T3 (A3)_R3.dwg";
                    if (!System.IO.File.Exists(savePath))
                    {
                        FileInfo fileTK = new FileInfo(savePath);

                        if (!System.IO.Directory.Exists(fileTK.Directory.FullName))
                        {
                            System.IO.Directory.CreateDirectory(fileTK.Directory.FullName);
                        }

                        System.IO.File.Copy(fsdTK, savePath, true);
                    }
                    System.Data.DataTable dtPC = new System.Data.DataTable();
                    System.Data.DataTable dtP = new System.Data.DataTable();
                    System.Data.DataTable dt = new System.Data.DataTable();
                    string filepath = frm.filePileName;
                    System.IO.FileInfo file = new FileInfo(filepath);
                    if (file.Extension.Contains("xlsx"))
                        dt = new FDEECommonTools.ExcelHelper().ExcelToTableForXLSX(filepath);
                    else
                        dt = FDEECommonTools.CVSTools.OpenCSV(filepath);
                    DataView dv0 = dt.DefaultView;
                    dt = dv0.ToTable(true, new string[] { "Type" , "Dia.", "Dowel", "Length" });
                    dtP = dv0.ToTable(true, new string[] { "Pier No." });
                    dtP.Columns[0].ColumnName = "PierNo";
                    System.Data.DataTable dtC= dv0.ToTable(true, new string[] { "Pier No.", "Pile No.", "Type", "Dia.", "Length", "Coord N", "Coord E", "Cut", "Dowel" });
                    dtC.Columns[0].ColumnName = "PierNo";
                    dtC.Columns[1].ColumnName = "PileNo";
                    dtC.Columns[3].ColumnName = "Dia";
                    dtC.Columns[5].ColumnName = "CoordN";
                    dtC.Columns[6].ColumnName = "CoordE";

                    string pile = string.Format("{0} TO {1}", dtP.Rows[0][0].ToString(), dtP.Rows[dtP.Rows.Count-1][0].ToString());
                    string pileNames = string.Format("{0}-{1}", dtP.Rows[0][0].ToString(), dtP.Rows[dtP.Rows.Count - 1][0].ToString());
                  
                    dtPC = dtC.Clone();
                   
                    foreach (System.Data.DataColumn col in dtPC.Columns)
                    {
                        if (col.ColumnName== "Dia")
                        {
                            col.DataType = typeof(Double);
                            //col.Expression = "0.000";
                        }
                        else  if (col.ColumnName == "Length")
                        {
                            col.DataType = typeof(Double);
                            //col.Expression = "0.000";
                        }
                        else if (col.ColumnName == "Dowel")
                        {
                            col.DataType = typeof(Double);
                            //col.Expression = "0.000";
                        }
                    }
                    foreach (DataRow row in dtC.Rows)
                    {
                        DataRow dr = dtPC.NewRow();
                        dr["PierNo"] = row["PierNo"];
                        dr["PileNo"] = row["PileNo"];
                        dr["Type"] = row["Type"];
                        dr["Dia"] = Convert.ToDouble(row["Dia"]);
                        dr["Length"] = Convert.ToDouble(row["Length"]);
                        dr["CoordN"] = row["CoordN"];
                        dr["CoordE"] = row["CoordE"];
                        dr["Cut"] = row["Cut"];
                        dr["Dowel"] = Convert.ToDouble(row["Dowel"]) ;
                        dtPC.Rows.Add(dr.ItemArray);
                    }

                        List<PilePara> pilePLst = new List<PilePara>();
                    for (int i=0;i<dt.Rows.Count;i++)
                    {
                        if (double.Parse(dt.Rows[i]["Length"].ToString()) < 30)
                        {
                            System.Windows.MessageBox.Show("模板存在异常数据");
                            return;
                        }
                        else
                        {
                            PilePara par = new PilePara();
                            par.pileDia = double.Parse(dt.Rows[i]["Dia."].ToString());
                            par.pileLength = double.Parse(dt.Rows[i]["Length"].ToString());
                            par.DOWEL = double.Parse(dt.Rows[i]["Dowel"].ToString()) * 1000;
                            par.type = dt.Rows[i]["Type"].ToString();
                            switch (par.type)
                            {
                                case "TYPE1":
                                    par.eSubType = (int)EPileType.Type1;
                                    break;
                                case "TYPE2":
                                    par.eSubType = (int)EPileType.Type2;
                                    break;
                                case "TYPE3":
                                    par.eSubType = (int)EPileType.Type3;
                                    break;
                                case "TYPE4":
                                    par.eSubType = (int)EPileType.Type4;
                                    break;
                                case "TYPE5":
                                    par.eSubType = (int)EPileType.Type5;
                                    break;
                                case "TYPE6":
                                    par.eSubType = (int)EPileType.Type6;
                                    break;
                                case "TYPE7":
                                    par.eSubType = (int)EPileType.Type7;
                                    break;
                                case "TYPE1T":
                                    par.eSubType = (int)EPileType.Type1T;
                                    break;
                            }

                            pilePLst.Add(par);
                        }
                    }
                    RebarCollection reberList = new RebarCollection();
                    int OverAllScale = 1;
                    string structureName = "";
                    FDEE.Model.eConcreteClass eConType = FDEE.Model.eConcreteClass.None;
                    double conValue = 0;
                    string path = "";//构造物

                    path = CurPaht.curPaht + @"DWG\桩基块.dwg";//构造物
                    //int page = 2;
                    //PilePara par = frm.pilePara;
                    List<MemberBase> rets = new List<MemberBase>();
                    List<Tuple<MemberBase, List<Tuple<string, int>>,PilePara,int >> tuLst = new List<Tuple<MemberBase, List<Tuple<string, int>>, PilePara, int>>();
                    List<Tuple<string, int>> tu = new List<Tuple<string, int>>();

                    #region  图纸绘制

                    #region 平面坐标之后图纸
                    #region  钢筋构造以及算量
                    for (int i = 0; i < pilePLst.Count; i++)
                    {
                        PileBase ret = FDEE.Model.MemberFactory.CreatMember((EPileType)pilePLst[i].eSubType, FDEE.Model.eSubType.None, pilePLst[i].pileLength, (int)(pilePLst[i].pileDia * 1000), (int)(pilePLst[i].DOWEL));

                        if (ret == null)
                        {
                            throw new System.Exception("数据异常");
                        }
                        MemberBase reBase = ret as MemberBase;
                        rets.Add(ret);
                        if (ret.RebarList != null && ret.RebarList.Count > 0)
                        {

                            try
                            {
                                new DrawingPileRebarStructure().DrawingPile(db, Point3d.Origin.Convert3D(-420, -195 - 297 * i), (EPileType)pilePLst[i].eSubType, pilePLst[i].pileLength, (int)(pilePLst[i].pileDia * 1000), (int)(pilePLst[i].DOWEL), ret.RebarList, path, i, 0);
                            }
                            catch { }
                            PlotPileTable.DrawingPileTable(db, reBase, path, pilePLst[i].type, pilePLst[i].pileLength, (int)pilePLst[i].DOWEL, pilePLst[i].pileDia,
                       eConType, out tu, i, 1);
                            string s = string.Format(@"Type='{0}' and Dia={1} and Dowel={2} and Length={3}", pilePLst[i].type, double.Parse(pilePLst[i].pileDia.ToString("0.000")), double.Parse((pilePLst[i].DOWEL * 0.001).ToString("0.000")), double.Parse(pilePLst[i].pileLength.ToString("0.000")));
                            //string s0 = string.Format(@"Type='{0}' and Dia='{1}' and Dowel='{2}' and Length='{3}'", pilePLst[i].type, pilePLst[i].pileDia, (pilePLst[i].DOWEL * 0.001), pilePLst[i].pileLength);
                            DataRow[] drs = dtPC.Select(s);
                            tuLst.Add(new Tuple<MemberBase, List<Tuple<string, int>>, PilePara, int>(reBase, tu, pilePLst[i], drs.Length));
                        }
                        else
                        {
                            throw new System.Exception("数据异常");
                        }
                    }
                    #endregion

                    #region UBolt 大样
                    new DrawingPileRebarStructure().DrawingPileUbolt(db, Point3d.Origin.Convert3D(0, -220 - 297 * (pilePLst.Count)), path, pilePLst.Count);
                    #endregion

                    #region 合并页
                    if (rets.Count > 0)
                    {

                        Point2d CT = Point2d.Origin.Convert2D(0, 297);
                        Point2d M1 = CT.Convert2D(0, -2 * OverAllScale);
                        PlotPileTable.DrawPileListMergeTB(db, M1.Convert3D(),
                                                 Extensions.curFont, OverAllScale, tuLst, pile, title, -1, 1, fsdTK);

                    }
                    #endregion
                    #endregion

                    #region 平面坐标图绘制
                    int pageCoorNum = 1;
                    Point2d CoorP = Point2d.Origin.Convert2D(0, 297 * 2);
                    Point2d MC = CoorP.Convert2D(0, -2 * OverAllScale);
                    PlotPileTable.DrawPileCoordinates(db, MC.Convert3D(), Extensions.curFont, OverAllScale, dtPC, dtP, out pageCoorNum, title, -2, 1, fsdTK);
                    #endregion

                    #region 目录列表生成
                    List<Tuple<int, string, string, int, int>> tuList = new List<Tuple<int, string, string, int, int>>(); //目录列表
                    #region 目录生成算法
                    int sn = 1;
                    int pageCoor = pageCoorNum;
                    int pageRebar = pilePLst.Count * 2;
                    string DrawNo = frm.dawingNo1;
                    int DrawNum = frm.dawingNo2;
                    string dN = DrawNo + DrawNum;
                    string DNA = "LIST OF DRAWING";
                    Tuple<int, string, string, int, int> tu1 = new Tuple<int, string, string, int, int>(sn, DNA, dN, 1, sn);
                    tuList.Add(tu1);
                    sn++;

                    for (int i = 0; i < pageCoorNum; i++)
                    {
                        if (pageCoorNum == 1)
                        {
                            dN = DrawNo + (DrawNum + (sn - 1));
                            DNA = "PILE COORDINATES FOR " + pile + " OF " + title;
                            tu1 = new Tuple<int, string, string, int, int>(sn, DNA, dN, 1, sn);
                            tuList.Add(tu1);
                            sn++;
                        }
                        else
                        {
                            dN = DrawNo + (DrawNum + (sn - 1));
                            DNA = "PILE COORDINATES FOR " + pile + " OF " + title + " " + (i + 1) + "/" + pageCoorNum;
                            tu1 = new Tuple<int, string, string, int, int>(sn, DNA, dN, 1, sn);
                            tuList.Add(tu1);
                            sn++;
                        }
                        db.CopyBlockFromFile(path, "ReferC");
                        BlockTool.InsertBlockReference(Point2d.Origin.Convert3D(17.5 + 420 * i, 297 * 2 + 297 - 10).Convert3D(), 1, "ReferC", path, 0, false);
                        TextPloter.PrintPaperMText(db, Point3d.Origin.Convert3D(218 + 420 * i, 19 + 297 * 2), DNA, 1);
                        TextPloter.PlotPaperText(db, Point3d.Origin.Convert3D(376 + 420 * i, 11.7 + 297 * 2), dN, 1);
                    }

                    dN = DrawNo + (DrawNum + (sn - 1));
                    DNA = "PILE LIST AND QUANTITIES FOR " + pile + " OF " + title;
                    tu1 = new Tuple<int, string, string, int, int>(sn, DNA, dN, 1, sn);
                    tuList.Add(tu1);
                    TextPloter.PrintPaperMText(db, Point3d.Origin.Convert3D(218 + 420, 19 + 297), DNA, 1);
                    TextPloter.PlotPaperText(db, Point3d.Origin.Convert3D(376 + 420, 11.7 + 297), dN, 1);
                    sn++;

                    for (int i = 0; i < pilePLst.Count; i++)
                    {
                        dN = DrawNo + (DrawNum + (sn - 1));
                        DNA = string.Format("REINFORCEMENT OF PILE DIA. {0}m-{1} PILE LENGTH {2}m 1/2", pilePLst[i].pileDia.ToString("0.00"), pilePLst[i].type, pilePLst[i].pileLength.ToString("0.00"));
                        tu1 = new Tuple<int, string, string, int, int>(sn, DNA, dN, 1, sn);
                        tuList.Add(tu1);
                        TextPloter.PrintPaperMText(db, Point3d.Origin.Convert3D(218, 18 - 297 * i), DNA, 1);
                        TextPloter.PlotPaperText(db, Point3d.Origin.Convert3D(376, 11.7 - 297 * i), dN, 1);
                        db.CopyBlockFromFile(path, "Refer");
                        BlockTool.InsertBlockReference(Point2d.Origin.Convert3D(420 - 7.5, -297 * i + 297 - 10).Convert3D(), 1, "Refer", path, 0, false);
                        sn++;

                        dN = DrawNo + (DrawNum + (sn - 1));
                        DNA = string.Format("REINFORCEMENT OF PILE DIA. {0}m-{1} PILE LENGTH {2}m 2/2", pilePLst[i].pileDia.ToString("0.00"), pilePLst[i].type, pilePLst[i].pileLength.ToString("0.00"));
                        tu1 = new Tuple<int, string, string, int, int>(sn, DNA, dN, 1, sn);
                        tuList.Add(tu1);
                        TextPloter.PrintPaperMText(db, Point3d.Origin.Convert3D(218 + 420, 18 - 297 * i), DNA, 1);
                        TextPloter.PlotPaperText(db, Point3d.Origin.Convert3D(376 + 420, 11.7 - 297 * i), dN, 1);
                        sn++;
                    }

                    dN = DrawNo + (DrawNum + (sn - 1));
                    DNA = "DETAIL OF U-BOLT";
                    tu1 = new Tuple<int, string, string, int, int>(sn, DNA, dN, 1, sn);
                    tuList.Add(tu1);

                    TextPloter.PrintPaperMText(db, Point3d.Origin.Convert3D(218, 18 - 297 * (pilePLst.Count)), DNA, 1);
                    TextPloter.PlotPaperText(db, Point3d.Origin.Convert3D(376, 11.7 - 297 * (pilePLst.Count)), dN, 1);
                    sn++;
                    #endregion
                    Point2d CTL = Point2d.Origin.Convert2D(0, 297 * 3);
                    Point2d M1L = CTL.Convert2D(0, -2 * OverAllScale);
                    PlotPileTable.DrawPileCatalogue(db, M1L.Convert3D(),
                                             Extensions.curFont, OverAllScale, tuList, -3, 1, fsdTK);

                    TextPloter.PrintPaperMText(db, Point3d.Origin.Convert3D(218 + 420, 18 + 297 * 3), tuList[0].Item2, 1);
                    TextPloter.PlotPaperText(db, Point3d.Origin.Convert3D(376 + 420, 11.7 + 297 * 3), tuList[0].Item3, 1);
                    #endregion

                    #endregion

                    #region 添加桩基编号
                    if (frm.AutoMark)
                    {
                        try
                        {
                            System.Data.DataTable dtPB = dv0.ToTable(true, new string[] { "Pier No.", "Pile No.", "Coord N", "Coord E" });
                            dtPB.Columns[0].ColumnName = "PierNo";
                            dtPB.Columns[1].ColumnName = "PileNo";
                            dtPB.Columns[2].ColumnName = "CoordN";
                            dtPB.Columns[3].ColumnName = "CoordE";

                            foreach (System.Data.DataRow dr in dtP.Rows)
                            {
                                System.Data.DataRow[] drs = dtPB.Select("PierNo='" + dr["PierNo"].ToString() + "'");

                                //Point2d pt = new Point2d(double.Parse(dr["CoordE"].ToString()), double.Parse(dr["CoordN"].ToString()));
                                //string txt = dr["PileNo"].ToString();
                                List<System.Data.DataRow> drLst = drs.OrderBy(o => o["PierNo"]).ThenBy(o => o["CoordE"]).ThenBy(o => o["CoordN"]).ToList();
                                foreach (System.Data.DataRow row in drLst)
                                {
                                    Point2d pt = new Point2d(double.Parse(row["CoordE"].ToString()), double.Parse(row["CoordN"].ToString()));
                                    string txt = row["PileNo"].ToString();
                                    Extents2d ext = new Extents2d(pt, pt);
                                    if (drLst.Count != 5)
                                    {
                                        if (int.Parse(txt) % 2 == 0)
                                            TextPloter.PlotTextMid(db, ref ext, pt.Convert3D(0, -2), txt, 1, 2, Extensions.curFont, GeTools.DegreeToRadian(frm.markRot));
                                        else
                                            TextPloter.PlotTextMid(db, ref ext, pt.Convert3D(0, 2), txt, 1, 2, Extensions.curFont, GeTools.DegreeToRadian(frm.markRot));
                                    }
                                    else
                                    {
                                        if (int.Parse(txt) <= 2)
                                            TextPloter.PlotTextMid(db, ref ext, pt.Convert3D(2), txt, 1, 2, Extensions.curFont, GeTools.DegreeToRadian(frm.markRot));
                                        else
                                            TextPloter.PlotTextMid(db, ref ext, pt.Convert3D(-2), txt, 1, 2, Extensions.curFont, GeTools.DegreeToRadian(frm.markRot));
                                    }

                                }
                            }
                        }
                        catch { }
                    }
                    #endregion

                    Extensions.SaveActiveDrawing(db, "桩基钢筋(" + pileNames + ")图纸" + DateTime.Now.ToString("yyyyMMddHHmmss"), title);

                    #region 封面生成
                    string filePath = CurPaht.curPaht + "OUTDWG\\";
                    AsposeWordTools wordTool = new AsposeWordTools(CurPaht.curPaht + "DWG\\封面.docx",filePath + title + "\\桩基钢筋(" + pileNames + ")封面" + DateTime.Now.ToString("yyyyMMdd") + ".docx");
                    wordTool.markToTxt("Pier", pile+" AT "+title);
                    wordTool.markToTxt("Date", DateTime.Now.ToString("MMMM", CultureInfo.GetCultureInfo("en-US"))+","+DateTime.Now.Year);
                    wordTool.save();
                    #endregion


               
                }
                catch (System.Exception ex)
                {
                    return;
                }
            }
        }
    }
}
